I den två första deluppgifterna kan vi simulera hela händelseförloppet, ett tidssteg i taget. Vi kan hålla en lista med alla vagnar i hjulet där vi lagrar hur många varv laget som just nu sitter i i vagnen har kvar att åka. För varje tidssteg tittar vi på vagnen som just nu är i botten, och eventuellt tar ut och sätter in ett lag i den. När det sista laget stiger ut svarar vi med antalet tidssteg.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fractions | |
def get_target_cmp(more, mandates): | |
assert mandates % 2 == 1 | |
more_cmps = [[votes / 1.2, idx] for idx, votes in enumerate(more)] | |
more_mandates = [0] * len(more) | |
more_mandate_cmps = [] | |
for i in range(mandates // 2 + 1): | |
more_cmps.sort(reverse=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import itertools | |
import math | |
import requests | |
import zipfile | |
import json | |
import collections | |
import csv | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import datetime | |
import urllib.request | |
import time | |
import collections | |
URL = "https://ranking.cmsioi2023.hu/sublist/" | |
ONLY_IMPROVEMENTS = False # Only prints submissions that improves a contestant's score | |
NAMES = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
#define rep(i, a, b) for(int i = a; i < (b); ++i) | |
#define trav(it, v) for(auto& it : v) | |
#define all(x) begin(x), end(x) | |
#define sz(x) (int)(x).size() | |
typedef long long ll; | |
typedef pair<int, int> pii; | |
typedef vector<int> vi; |
I hereby claim:
- I am jsannemo on github.
- I am jsannemo (https://keybase.io/jsannemo) on keybase.
- I have a public key ASAHTStlhYG3_AB9ex0kLZueC7pPZ67YVguyxcJPlNM6Mwo
To claim this, I am signing this object:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rep(i,0,sz(B)) { | |
A[i - B[i] + 1] = max(A[i - B[i] + 1], B[i]); | |
} | |
rep(i,0,sz(A)) { | |
if (B[i] && A[B[i] - 1]) | |
A[i] = max(A[i], B[A[B[i] - 1] - 1]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct PR { | |
void ins(int x) { (a == -1 ? a : b) = x; } | |
void rem(int x) { (a == x ? a : b) = -1; } | |
int cnt() { return (a != -1) + (b != -1); } | |
int a, b; | |
}; | |
struct F { | |
P3 norm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pair<double, P> enclosingCircle(vector<P> S) { | |
int a, b; | |
tie(a, b) = polygonDiameter(S); | |
P C = (S[a] + S[b]) / 2; | |
double R = (C - S[a]).dist2(); | |
trav(it, S) { | |
double NR = (C - it).dist2(); | |
if (NR > R * (1 + 1e-9)) { | |
C = ccCenter(S[a], S[b], it); | |
R = (C - S[a]).dist2(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector<pii> antipodal(const vector<P>& S, const vi& U, const vi& L) { | |
vector<pii> A; | |
int i = 0; | |
int j = sz(L) - 1; | |
while (i < sz(U) - 1 || j > 0) { | |
A.emplace_back(U[i], L[j]); | |
if (i != sz(U) - 1 && (j == 0 || (S[L[j]] - S[L[j-1]]).cross((S[U[i+1]] - S[U[i]])) > 0)) ++i; | |
else --j; | |
} | |
return A; |
NewerOlder