Submission #415141

# Submission time Handle Problem Language Result Execution time Memory
415141 2021-05-31T15:09:46 Z Bill_00 The Big Prize (IOI17_prize) C++14
97.63 / 100
85 ms 1992 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
int l[200005],r[200005],x[200005],answer=-1;
void solve(int L,int R){
	if(answer!=-1) return;
	if(L+1==R){
		return;
	}
	int m=(L+R)>>1;
	vector<int>res=ask(m);
	l[m]=res[0];
	r[m]=res[1];
	if(l[m]+r[m]==0){
		answer=m;
		return;
	}
	if(l[m]!=l[L] || r[m]!=r[L]){
		solve(L,m);
	}
	if(answer!=-1) return;
	if(l[m]!=l[R] || r[m]!=r[R]){
		solve(m,R);
	}
}
int find_best(int n){
	// for(int i = 0; i < n; i++){
	// 	std::vector<int> res = ask(i);
	// 	if(res[0] + res[1] == 0)
	// 		return i;
	// }
	for(int i=0;i<n;i++){
		l[i]=r[i]=-1;
	}
	int m=(n-1)/2;
	vector<int>res=ask(0);
	l[0]=res[0];
	r[0]=res[1];
	if(l[0]+r[0]==0) return 0;
	res=ask(n-1);
	l[n-1]=res[0];
	r[n-1]=res[1];
	if(l[n-1]+r[n-1]==0) return n-1;
	solve(0,n-1);
	return answer;
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:35:6: warning: unused variable 'm' [-Wunused-variable]
   35 |  int m=(n-1)/2;
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1736 KB Output is correct
2 Correct 3 ms 1828 KB Output is correct
3 Correct 2 ms 1824 KB Output is correct
4 Correct 2 ms 1864 KB Output is correct
5 Correct 2 ms 1740 KB Output is correct
6 Correct 2 ms 1820 KB Output is correct
7 Correct 2 ms 1760 KB Output is correct
8 Correct 2 ms 1736 KB Output is correct
9 Correct 2 ms 1808 KB Output is correct
10 Correct 3 ms 1736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1832 KB Output is correct
2 Correct 3 ms 1824 KB Output is correct
3 Correct 2 ms 1864 KB Output is correct
4 Correct 2 ms 1824 KB Output is correct
5 Correct 2 ms 1864 KB Output is correct
6 Correct 2 ms 1864 KB Output is correct
7 Correct 2 ms 1820 KB Output is correct
8 Correct 2 ms 1736 KB Output is correct
9 Correct 2 ms 1736 KB Output is correct
10 Correct 2 ms 1864 KB Output is correct
11 Correct 5 ms 1828 KB Output is correct
12 Correct 2 ms 1816 KB Output is correct
13 Correct 10 ms 1864 KB Output is correct
14 Correct 2 ms 456 KB Output is correct
15 Correct 7 ms 1864 KB Output is correct
16 Correct 67 ms 1824 KB Output is correct
17 Correct 2 ms 1828 KB Output is correct
18 Partially correct 37 ms 1728 KB Partially correct - number of queries: 5068
19 Correct 2 ms 1736 KB Output is correct
20 Correct 25 ms 968 KB Output is correct
21 Correct 26 ms 1736 KB Output is correct
22 Correct 4 ms 1864 KB Output is correct
23 Correct 2 ms 1820 KB Output is correct
24 Correct 2 ms 1820 KB Output is correct
25 Correct 24 ms 1824 KB Output is correct
26 Correct 13 ms 1824 KB Output is correct
27 Correct 3 ms 1816 KB Output is correct
28 Correct 71 ms 1820 KB Output is correct
29 Correct 50 ms 1736 KB Output is correct
30 Partially correct 85 ms 1816 KB Partially correct - number of queries: 5022
31 Correct 3 ms 1816 KB Output is correct
32 Correct 5 ms 1864 KB Output is correct
33 Correct 1 ms 200 KB Output is correct
34 Correct 31 ms 1824 KB Output is correct
35 Correct 3 ms 1828 KB Output is correct
36 Correct 11 ms 1728 KB Output is correct
37 Correct 2 ms 1820 KB Output is correct
38 Correct 2 ms 1736 KB Output is correct
39 Correct 13 ms 1824 KB Output is correct
40 Correct 41 ms 1824 KB Output is correct
41 Correct 15 ms 1856 KB Output is correct
42 Correct 16 ms 1864 KB Output is correct
43 Correct 37 ms 1728 KB Output is correct
44 Correct 26 ms 1728 KB Output is correct
45 Correct 24 ms 1820 KB Output is correct
46 Correct 2 ms 1820 KB Output is correct
47 Correct 20 ms 1820 KB Output is correct
48 Correct 50 ms 1864 KB Output is correct
49 Correct 7 ms 1864 KB Output is correct
50 Partially correct 26 ms 1820 KB Partially correct - number of queries: 5070
51 Correct 13 ms 1820 KB Output is correct
52 Correct 3 ms 1728 KB Output is correct
53 Correct 3 ms 1804 KB Output is correct
54 Correct 33 ms 1736 KB Output is correct
55 Correct 2 ms 1752 KB Output is correct
56 Partially correct 70 ms 1736 KB Partially correct - number of queries: 5069
57 Correct 32 ms 1820 KB Output is correct
58 Correct 54 ms 1816 KB Output is correct
59 Correct 42 ms 1728 KB Output is correct
60 Correct 43 ms 1820 KB Output is correct
61 Correct 5 ms 1992 KB Output is correct
62 Correct 3 ms 1828 KB Output is correct
63 Correct 4 ms 1808 KB Output is correct
64 Correct 3 ms 1828 KB Output is correct
65 Correct 3 ms 1816 KB Output is correct
66 Correct 3 ms 1736 KB Output is correct
67 Correct 2 ms 1736 KB Output is correct
68 Correct 2 ms 1820 KB Output is correct
69 Correct 3 ms 1864 KB Output is correct
70 Correct 2 ms 1728 KB Output is correct
71 Correct 74 ms 1864 KB Output is correct
72 Correct 4 ms 1864 KB Output is correct
73 Correct 75 ms 1736 KB Output is correct
74 Correct 64 ms 1864 KB Output is correct
75 Correct 4 ms 1864 KB Output is correct
76 Correct 28 ms 1736 KB Output is correct
77 Partially correct 26 ms 1864 KB Partially correct - number of queries: 5216
78 Correct 8 ms 1864 KB Output is correct
79 Correct 37 ms 1824 KB Output is correct
80 Partially correct 77 ms 1736 KB Partially correct - number of queries: 5237
81 Partially correct 78 ms 1736 KB Partially correct - number of queries: 5218
82 Partially correct 80 ms 1864 KB Partially correct - number of queries: 5216
83 Correct 4 ms 1828 KB Output is correct
84 Correct 21 ms 1864 KB Output is correct
85 Partially correct 61 ms 1828 KB Partially correct - number of queries: 5233
86 Correct 16 ms 1736 KB Output is correct
87 Correct 6 ms 1864 KB Output is correct
88 Correct 10 ms 1764 KB Output is correct
89 Correct 13 ms 1864 KB Output is correct
90 Correct 4 ms 1736 KB Output is correct
91 Correct 9 ms 1864 KB Output is correct
92 Correct 2 ms 1864 KB Output is correct
93 Correct 6 ms 1736 KB Output is correct
94 Correct 5 ms 1864 KB Output is correct
95 Correct 4 ms 1864 KB Output is correct
96 Correct 8 ms 1864 KB Output is correct
97 Correct 2 ms 1864 KB Output is correct