Submission #248793

#TimeUsernameProblemLanguageResultExecution timeMemory
248793kostia244The Big Prize (IOI17_prize)C++17
0 / 100
5 ms3828 KiB
#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, pg;
	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]) || count(all(pg), p[nj])) {
					nj++;
					continue;
				}
				vi t = ask(p[nj]);
				if(t[0]+t[1] < cg) pg.push_back(p[nj++]);
				else break;
			}
			if(nj >= p.size()) continue;
			//cout << j << " // " << nj << " " << ask(p[nj])[0] << endl;
			if(ask(p[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 = min((int)p.size()-1, nj);
		//if(j != 1999)
		//cout << j << " " << g.size() << " " << cg << " " << ask(p[nj])[0] << endl;
	}
	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)

prize.cpp: In function 'int solve(std::vector<int>)':
prize.cpp:24:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while(nj < p.size()) {
          ~~~^~~~~~~~~~
prize.cpp:33:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(nj >= p.size()) continue;
       ~~~^~~~~~~~~~~
prize.cpp:38:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(nj < p.size()) {
         ~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...