Submission #295917

#TimeUsernameProblemLanguageResultExecution timeMemory
295917Aldas25The Big Prize (IOI17_prize)C++14
90 / 100
105 ms5628 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr) #define FOR(i, a, b) for(int i = (a); i <= (b); i++) #define REP(n) FOR(O, 1, (n)) #define pb push_back #define f first #define s second typedef long double ld; typedef long long ll; typedef pair<int, int> pii; typedef pair<int, pii> piii; typedef vector<int> vi; typedef vector<pii> vii; typedef vector<ll> vl; typedef vector<piii> viii; mt19937 rng (chrono::steady_clock::now().time_since_epoch().count()); const int MAXN = 200100; bool ch[MAXN]; vi got[MAXN]; vi get (int id) { if(!ch[id]) { ch[id] = true; got[id] = ask(id); } return got[id]; } int brute_find (int n){ FOR(i, 0, n-1) { vi a = get(i); if (a[0] + a[1] == 0) return i; } return 0; } int find_best(int n) { if (n <= 5000) return brute_find(n); int bg = 0; /// bg = 0 int m = 1000; /// m = 1000 FOR(i, 0, m-1) { vi a = get(i); if (a[0] + a[1] == 0) return i; bg = max(bg, a[0]+a[1]); } FOR(i, 0, n-1) { vi a = get(i); if (a[0] + a[1] == 0) return i; if (a[0] + a[1] == bg) { int le = i, ri = n-1; while (le < ri) { int mid = (le+ri+1)/2; vi a2 = get(mid); while (a2[0] + a2[1] != bg) { if (a2[0] + a2[1] == 0) return mid; mid--; ri = mid; a2 = get(mid); } if (a2[0] != a[0]) ri = mid-1; else le = mid; } i = le; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...