# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
248786 | kostia244 | The Big Prize (IOI17_prize) | C++17 | 89 ms | 2036 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "prize.h"
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using vi = vector<int>;
int solve(vector<int> p) {
if(p.size() < 100) {
for(auto i : p) {
std::vector<int> res = ask(i);
if(res[0] + res[1] == 0)
return i;
}
}
int cntbad = 0, cg;
vi g;
for(int i = 0; i < 35; i++) {
vi t = ask(p[i]);
cntbad = max(cntbad, (int)p.size() - t[0] - t[1]);
}
cg = p.size() - cntbad;
for(int j = 0, i = 0; i < cg;) {
for(int z = 1<<18; z>>=1;) {
int nj = j+z;
while(nj < p.size()) {
if(count(all(g), p[nj])) {
nj++;
continue;
}
vi t = ask(p[nj]);
if(t[0]+t[1] < cg) g.push_back(p[nj++]);
else break;
}
if(nj >= p.size()) continue;
if(ask(nj)[0] < i) j = nj;
}
int nj = j+1;
while(nj < p.size()) {
if(count(all(g), p[nj])) {
nj++;
continue;
}
vi t = ask(p[nj]);
if(t[0]+t[1] < cg) g.push_back(p[nj++]);
else break;
}
i = g.size();
j = nj;
}
return solve(g);
}
int find_best(int n) {
vi t;
for(int i = 0; i < n; i++) t.push_back(i);
return solve(t);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |