Submission #850992

# Submission time Handle Problem Language Result Execution time Memory
850992 2023-09-18T07:02:08 Z 12345678 The Big Prize (IOI17_prize) C++17
100 / 100
32 ms 6700 KB
#include "prize.h"
#include <bits/stdc++.h>

using namespace std;

mt19937 rng(time(0));

const int nx=2e5+5;
int w, N, ans, mx,cnt, rd;
bool s;
vector<int> m[nx];

vector<int> ask2(int x)
{
	if (x<0||x>=mx) return vector<int> (2, 0);
	if (m[x].empty()) 
	{
		m[x]=ask(x);
		if (m[x][0]+m[x][1]==0) ans=x, s=1;
		return m[x];
	}
	return m[x];
}

void solve(int l, int r)
{
	if (l>r||s) return;
	if (l==r) return ask2(l), void();
	int ml=(l+r)/2, mr=(l+r)/2;
	while (ml>=l&&ask2(ml)[0]+ask2(ml)[1]!=w) ml--;
	while (mr<=r&&ask2(mr)[0]+ask2(mr)[1]!=w) mr++;
	if (ask2(ml)[0]-ask2(l-1)[0]>0) solve(l, ml-1);
	if (ask2(mr)[1]-ask2(r+1)[1]>0) solve(mr+1, r);
}

int find_best(int n) {
	mx=n;
	for (int i=0; i<=100; i++) rd=(rng()%n+n)%n, w=max(w, ask2(rd)[0]+ask2(rd)[1]);
	int l=0, r=n-1;
	//while (ask2(l)[0]+ask2(l)[1]!=w) l++;
	//while (ask2(r)[0]+ask2(r)[1]!=w) r--;
	solve(l, r);
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5136 KB Output is correct
2 Correct 3 ms 5144 KB Output is correct
3 Correct 2 ms 5136 KB Output is correct
4 Correct 2 ms 5140 KB Output is correct
5 Correct 2 ms 5136 KB Output is correct
6 Correct 2 ms 5144 KB Output is correct
7 Correct 2 ms 5144 KB Output is correct
8 Correct 2 ms 5140 KB Output is correct
9 Correct 2 ms 5140 KB Output is correct
10 Correct 2 ms 5136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5136 KB Output is correct
2 Correct 2 ms 5144 KB Output is correct
3 Correct 2 ms 5136 KB Output is correct
4 Correct 2 ms 5144 KB Output is correct
5 Correct 2 ms 5136 KB Output is correct
6 Correct 2 ms 5380 KB Output is correct
7 Correct 2 ms 5140 KB Output is correct
8 Correct 2 ms 5140 KB Output is correct
9 Correct 2 ms 5140 KB Output is correct
10 Correct 2 ms 5140 KB Output is correct
11 Correct 4 ms 5396 KB Output is correct
12 Correct 2 ms 5140 KB Output is correct
13 Correct 4 ms 5396 KB Output is correct
14 Correct 2 ms 5400 KB Output is correct
15 Correct 4 ms 5416 KB Output is correct
16 Correct 20 ms 5956 KB Output is correct
17 Correct 3 ms 5136 KB Output is correct
18 Correct 30 ms 6456 KB Output is correct
19 Correct 2 ms 5140 KB Output is correct
20 Correct 6 ms 5428 KB Output is correct
21 Correct 12 ms 5664 KB Output is correct
22 Correct 4 ms 5400 KB Output is correct
23 Correct 2 ms 5140 KB Output is correct
24 Correct 2 ms 5140 KB Output is correct
25 Correct 18 ms 5676 KB Output is correct
26 Correct 15 ms 5920 KB Output is correct
27 Correct 2 ms 5140 KB Output is correct
28 Correct 18 ms 5944 KB Output is correct
29 Correct 14 ms 5940 KB Output is correct
30 Correct 21 ms 5508 KB Output is correct
31 Correct 2 ms 5136 KB Output is correct
32 Correct 4 ms 5224 KB Output is correct
33 Correct 1 ms 4952 KB Output is correct
34 Correct 10 ms 5396 KB Output is correct
35 Correct 3 ms 5396 KB Output is correct
36 Correct 7 ms 5920 KB Output is correct
37 Correct 2 ms 5132 KB Output is correct
38 Correct 2 ms 5140 KB Output is correct
39 Correct 16 ms 5396 KB Output is correct
40 Correct 18 ms 6700 KB Output is correct
41 Correct 13 ms 5716 KB Output is correct
42 Correct 16 ms 5692 KB Output is correct
43 Correct 12 ms 5676 KB Output is correct
44 Correct 12 ms 5916 KB Output is correct
45 Correct 7 ms 5684 KB Output is correct
46 Correct 2 ms 5136 KB Output is correct
47 Correct 10 ms 5408 KB Output is correct
48 Correct 20 ms 5656 KB Output is correct
49 Correct 3 ms 5400 KB Output is correct
50 Correct 28 ms 5456 KB Output is correct
51 Correct 8 ms 5688 KB Output is correct
52 Correct 2 ms 5148 KB Output is correct
53 Correct 3 ms 5656 KB Output is correct
54 Correct 13 ms 5672 KB Output is correct
55 Correct 2 ms 5136 KB Output is correct
56 Correct 26 ms 5980 KB Output is correct
57 Correct 14 ms 5964 KB Output is correct
58 Correct 17 ms 6220 KB Output is correct
59 Correct 11 ms 5652 KB Output is correct
60 Correct 13 ms 5660 KB Output is correct
61 Correct 2 ms 5396 KB Output is correct
62 Correct 2 ms 5140 KB Output is correct
63 Correct 2 ms 5140 KB Output is correct
64 Correct 2 ms 5140 KB Output is correct
65 Correct 2 ms 5140 KB Output is correct
66 Correct 4 ms 5656 KB Output is correct
67 Correct 4 ms 5664 KB Output is correct
68 Correct 5 ms 5148 KB Output is correct
69 Correct 3 ms 5408 KB Output is correct
70 Correct 5 ms 5140 KB Output is correct
71 Correct 32 ms 5712 KB Output is correct
72 Correct 3 ms 5152 KB Output is correct
73 Correct 31 ms 5996 KB Output is correct
74 Correct 20 ms 5504 KB Output is correct
75 Correct 3 ms 5140 KB Output is correct
76 Correct 22 ms 5672 KB Output is correct
77 Correct 22 ms 5924 KB Output is correct
78 Correct 4 ms 5656 KB Output is correct
79 Correct 12 ms 5680 KB Output is correct
80 Correct 29 ms 6340 KB Output is correct
81 Correct 26 ms 5676 KB Output is correct
82 Correct 23 ms 6444 KB Output is correct
83 Correct 2 ms 5396 KB Output is correct
84 Correct 23 ms 5908 KB Output is correct
85 Correct 25 ms 5984 KB Output is correct
86 Correct 10 ms 5400 KB Output is correct
87 Correct 3 ms 5644 KB Output is correct
88 Correct 7 ms 6164 KB Output is correct
89 Correct 6 ms 5656 KB Output is correct
90 Correct 2 ms 5336 KB Output is correct
91 Correct 6 ms 5652 KB Output is correct
92 Correct 5 ms 5900 KB Output is correct
93 Correct 4 ms 5396 KB Output is correct
94 Correct 3 ms 5396 KB Output is correct
95 Correct 4 ms 5396 KB Output is correct
96 Correct 3 ms 5396 KB Output is correct
97 Correct 2 ms 5136 KB Output is correct