Submission #283920

# Submission time Handle Problem Language Result Execution time Memory
283920 2020-08-26T09:38:24 Z emanIaicepsa The Big Prize (IOI17_prize) C++14
98.87 / 100
65 ms 6100 KB
#include "prize.h"
#include<bits/stdc++.h>
#define vi vector<int>
using namespace std;

vi ans[200005];
int asked[200005];
set<int> s;
vector<int> Ask(int x){
	if(!asked[x]) ans[x] = ask(x), asked[x] = 1, s.insert(x);
	return ans[x];
}

int find_best(int n) {
	srand(time(0));
	if(n <= 5000){
		for(int i=0;i<n;i++){
			vi tmp = Ask(i);
			if(tmp[0] + tmp[1] == 0) return i;
		}
	}
	int mx = 0;

	for(int i=0;i<10;i++){
		int x = rand() % n;
		vi tmp = Ask(x);
		mx = max(mx, tmp[0] + tmp[1]);
	}

	int l = 0;
	vi cur;
	while(1){
		cur = Ask(l);
		if(cur[0] == 0 && cur[1] == 0) return l;
		if(cur[0] + cur[1] < mx) l++;
		else break;
	}
	while(l < n){
		auto iter = s.begin();
		while(!s.empty() && (*iter < l || Ask(*iter) == Ask(l))) iter = s.erase(iter);
		int L = l, R = s.empty() ? n-1 : *s.begin();
		while(L < R){
			int m = (L+R+1)/2;
			vi tmp = Ask(m);
			if(tmp[0] != cur[0] || tmp[1] != cur[1]) R = m - 1;
			else L = m;
		}
		if(L == n-1) break;
		l = L+1;
		while(1){
			if(l == n) break;
			cur = Ask(l);
			if(cur[0] == 0 && cur[1] == 0) return l;
			if(cur[0] + cur[1] < mx) l++;
			else break;
		}
	}
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:31:5: warning: control reaches end of non-void function [-Wreturn-type]
   31 |  vi cur;
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5112 KB Output is correct
2 Correct 4 ms 5120 KB Output is correct
3 Correct 4 ms 5112 KB Output is correct
4 Correct 4 ms 5120 KB Output is correct
5 Correct 4 ms 5112 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 5 ms 5112 KB Output is correct
8 Correct 4 ms 5120 KB Output is correct
9 Correct 5 ms 5120 KB Output is correct
10 Correct 4 ms 5120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5120 KB Output is correct
2 Correct 5 ms 5120 KB Output is correct
3 Correct 4 ms 5120 KB Output is correct
4 Correct 4 ms 5160 KB Output is correct
5 Correct 4 ms 5112 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 4 ms 5120 KB Output is correct
8 Correct 4 ms 5060 KB Output is correct
9 Correct 4 ms 5112 KB Output is correct
10 Correct 4 ms 5120 KB Output is correct
11 Correct 7 ms 5240 KB Output is correct
12 Correct 4 ms 4992 KB Output is correct
13 Correct 9 ms 5504 KB Output is correct
14 Correct 5 ms 5076 KB Output is correct
15 Correct 11 ms 5248 KB Output is correct
16 Correct 55 ms 5880 KB Output is correct
17 Correct 5 ms 5120 KB Output is correct
18 Partially correct 35 ms 5964 KB Partially correct - number of queries: 5113
19 Correct 4 ms 5120 KB Output is correct
20 Correct 19 ms 5184 KB Output is correct
21 Correct 28 ms 5368 KB Output is correct
22 Correct 9 ms 5120 KB Output is correct
23 Correct 4 ms 5120 KB Output is correct
24 Correct 4 ms 4992 KB Output is correct
25 Correct 28 ms 5496 KB Output is correct
26 Correct 30 ms 5576 KB Output is correct
27 Correct 5 ms 5120 KB Output is correct
28 Correct 55 ms 5856 KB Output is correct
29 Correct 34 ms 5752 KB Output is correct
30 Partially correct 57 ms 5880 KB Partially correct - number of queries: 5056
31 Correct 4 ms 5112 KB Output is correct
32 Correct 8 ms 5368 KB Output is correct
33 Correct 3 ms 4992 KB Output is correct
34 Correct 23 ms 5368 KB Output is correct
35 Correct 6 ms 5248 KB Output is correct
36 Correct 16 ms 5248 KB Output is correct
37 Correct 5 ms 5116 KB Output is correct
38 Correct 4 ms 5248 KB Output is correct
39 Correct 29 ms 5460 KB Output is correct
40 Correct 40 ms 5880 KB Output is correct
41 Correct 38 ms 5624 KB Output is correct
42 Correct 20 ms 5672 KB Output is correct
43 Correct 44 ms 5496 KB Output is correct
44 Correct 15 ms 5408 KB Output is correct
45 Correct 19 ms 5368 KB Output is correct
46 Correct 4 ms 4992 KB Output is correct
47 Correct 23 ms 5496 KB Output is correct
48 Correct 42 ms 5756 KB Output is correct
49 Correct 6 ms 5216 KB Output is correct
50 Partially correct 49 ms 5880 KB Partially correct - number of queries: 5068
51 Correct 26 ms 5368 KB Output is correct
52 Correct 5 ms 5112 KB Output is correct
53 Correct 5 ms 5248 KB Output is correct
54 Correct 25 ms 5496 KB Output is correct
55 Correct 4 ms 5120 KB Output is correct
56 Partially correct 52 ms 5880 KB Partially correct - number of queries: 5086
57 Correct 38 ms 5624 KB Output is correct
58 Correct 42 ms 5624 KB Output is correct
59 Correct 37 ms 5496 KB Output is correct
60 Correct 38 ms 5644 KB Output is correct
61 Correct 6 ms 5144 KB Output is correct
62 Correct 5 ms 5112 KB Output is correct
63 Correct 5 ms 5240 KB Output is correct
64 Correct 5 ms 5120 KB Output is correct
65 Correct 5 ms 5120 KB Output is correct
66 Correct 9 ms 5112 KB Output is correct
67 Correct 4 ms 5120 KB Output is correct
68 Correct 8 ms 5120 KB Output is correct
69 Correct 8 ms 5112 KB Output is correct
70 Correct 4 ms 5120 KB Output is correct
71 Correct 43 ms 5880 KB Output is correct
72 Correct 9 ms 5504 KB Output is correct
73 Correct 61 ms 5960 KB Output is correct
74 Correct 40 ms 6100 KB Output is correct
75 Correct 5 ms 5248 KB Output is correct
76 Correct 55 ms 5972 KB Output is correct
77 Partially correct 65 ms 6008 KB Partially correct - number of queries: 5044
78 Correct 9 ms 5504 KB Output is correct
79 Correct 30 ms 5880 KB Output is correct
80 Partially correct 50 ms 6084 KB Partially correct - number of queries: 5041
81 Partially correct 60 ms 5880 KB Partially correct - number of queries: 5051
82 Partially correct 56 ms 5884 KB Partially correct - number of queries: 5012
83 Correct 5 ms 5248 KB Output is correct
84 Correct 47 ms 5884 KB Output is correct
85 Partially correct 62 ms 5880 KB Partially correct - number of queries: 5057
86 Correct 15 ms 5496 KB Output is correct
87 Correct 8 ms 5248 KB Output is correct
88 Correct 11 ms 5376 KB Output is correct
89 Correct 10 ms 5376 KB Output is correct
90 Correct 5 ms 5120 KB Output is correct
91 Correct 9 ms 5248 KB Output is correct
92 Correct 4 ms 5248 KB Output is correct
93 Correct 8 ms 5376 KB Output is correct
94 Correct 9 ms 5376 KB Output is correct
95 Correct 8 ms 5376 KB Output is correct
96 Correct 7 ms 5504 KB Output is correct
97 Correct 4 ms 5120 KB Output is correct