Submission #512849

#TimeUsernameProblemLanguageResultExecution timeMemory
512849kevinxiehkThe Big Prize (IOI17_prize)C++17
20 / 100
97 ms13184 KiB
#include "prize.h" #include "bits/stdc++.h" using namespace std; int ddd = 1; int fen[200005][10]; int corr[10]; int n; unordered_map<int, int> aaa; void add(int id, int x, int k) { id++; while(id <= n) { fen[id][k] += x; id += (id & (-id)); } } int sum(int id, int k) { int ans = 0; id++; while(id > 0) { ans += fen[id][k]; id -= (id & (-id)); } return ans; } int getbefore(int id, int k) { int t = 0; for(int i = 1; i < ddd; i++) { if(corr[i] < k) t += sum(id, i); } return t; } void add_val(int a, int k) { if(aaa[k] == 0) {corr[ddd] = k; aaa[k] = ddd++;} add(a, 1, aaa[k]); } bool vi[200005]; vector<int> store[200005]; int now = 0; int dx = 0; int sign = 1; int l = 0; vector<int> aa(int t) { if(vi[t]) { int k = 0; while((t - k < l ||vi[t - k]) && (t + k >= n || vi[t + k])) k++; if(t - k >= l && !vi[t - k]) now = t = t - k; else now = t = t + k; } // vi[t] = true; return store[t] = ask(t); } int find_best(int N) { n = N; // int t = 100; while(1) { // cerr << now << '\n'; vector<int> res = aa(now); if(res[0] + res[1] == 0) return now; if(!vi[now]) add_val(now, res[0] + res[1]); vi[now] = true; if(res[0] == getbefore(now, res[0] + res[1])) { sign = 1; dx *= 2; l = now + 1; if(dx == 0) dx++; } else { sign = -1; dx /= 2; if(dx == 0) dx++; } if(sign == 1) dx = min(dx, n - 1 - now); else dx = min(dx, now - l); now += dx * sign; } // for(int i = 0; i < n; i++) { // vector<int> res = ask(i); // if(res[0] + res[1] == 0) // return i; // } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...