Submission #64597

# Submission time Handle Problem Language Result Execution time Memory
64597 2018-08-05T02:46:45 Z nvmdava The Big Prize (IOI17_prize) C++17
20 / 100
116 ms 5820 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
 
 
vector<int> ans[210000];
int mx = -1, ll, rr, Q = -1;
int find(int l, int r, int q){
	if(Q != -1){
		return 0;
	}
	if(ans[l][0] == ans[r][0]){
		return 0;
	}
	if(ll > r || rr < l){
		return 0;
	}
	int m = (l + r) >> 1, L = m, R = m + 1;
	while(l < L){
		if(L < ll){
			break;
		}
		ans[L] =ask(L);
		if(ans[L][0] + ans[L][1] == mx){
			break;
		}
		if(ans[L][0] + ans[L][1] == 0){
			Q = L;
			return L;
		}
		if(ans[L][0] == 0){
			ll = L + 1;
			break;
		}
		L--;
	}
	while(r > R){
		if(R > rr){
			break;
		}
		ans[R] =ask(R);
		if(ans[R][0] + ans[R][1] == mx){
			break;
		}
		if(ans[R][0] + ans[R][1] == 0){
			Q = R;
			return R;
		}
		if(ans[R][1] == 0){
			rr = R - 1;
			break;
		}
		R++;
	}
	if(q == 1){
		return max(find(l, L, 0), find(R, r, 0));
	}
	return max(find(l, L, 1), find(R, r, 1));
}
 
int find_best(int n) {
	ll = 0;
	rr = n - 1;
	for(int i = 0; i < 448; i++){
		ans[i] = ask(i);
		if(ans[i][0] + ans[i][1] == 0){
			return i;
		}
		mx = max(mx, ans[i][0] + ans[i][1]);
	}
	int l = 0, r = n - 1;
	while(true){
		if(ans[l][0] + ans[l][1] == mx){
			break;
		}
		l++;
	}
	while(true){
		
		ans[r] = ask(r);
		
		if(ans[r][0] + ans[r][1] == mx){
			break;
		}
		if(ans[r][0] + ans[r][1] == 0){
			return r;
		}
		r--;
	}
	return find(l, r, 0);
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 5156 KB Output is correct
2 Correct 9 ms 5316 KB Output is correct
3 Correct 11 ms 5336 KB Output is correct
4 Correct 15 ms 5364 KB Output is correct
5 Correct 12 ms 5440 KB Output is correct
6 Correct 7 ms 5440 KB Output is correct
7 Correct 10 ms 5532 KB Output is correct
8 Correct 14 ms 5532 KB Output is correct
9 Correct 10 ms 5532 KB Output is correct
10 Correct 13 ms 5532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 5532 KB Output is correct
2 Correct 12 ms 5532 KB Output is correct
3 Correct 11 ms 5532 KB Output is correct
4 Correct 15 ms 5532 KB Output is correct
5 Correct 10 ms 5532 KB Output is correct
6 Correct 7 ms 5532 KB Output is correct
7 Correct 11 ms 5532 KB Output is correct
8 Correct 13 ms 5580 KB Output is correct
9 Correct 14 ms 5580 KB Output is correct
10 Correct 11 ms 5580 KB Output is correct
11 Correct 16 ms 5580 KB Output is correct
12 Correct 14 ms 5580 KB Output is correct
13 Correct 14 ms 5580 KB Output is correct
14 Correct 34 ms 5580 KB Output is correct
15 Partially correct 53 ms 5584 KB Partially correct - number of queries: 6312
16 Correct 23 ms 5584 KB Output is correct
17 Correct 13 ms 5584 KB Output is correct
18 Correct 13 ms 5584 KB Output is correct
19 Partially correct 85 ms 5692 KB Partially correct - number of queries: 7570
20 Correct 36 ms 5692 KB Output is correct
21 Partially correct 58 ms 5692 KB Partially correct - number of queries: 5196
22 Partially correct 60 ms 5700 KB Partially correct - number of queries: 5661
23 Correct 17 ms 5700 KB Output is correct
24 Correct 23 ms 5700 KB Output is correct
25 Correct 38 ms 5700 KB Output is correct
26 Correct 39 ms 5700 KB Output is correct
27 Correct 9 ms 5700 KB Output is correct
28 Correct 14 ms 5700 KB Output is correct
29 Correct 27 ms 5700 KB Output is correct
30 Correct 9 ms 5700 KB Output is correct
31 Correct 15 ms 5700 KB Output is correct
32 Correct 18 ms 5700 KB Output is correct
33 Correct 7 ms 5700 KB Output is correct
34 Partially correct 85 ms 5700 KB Partially correct - number of queries: 5670
35 Correct 12 ms 5700 KB Output is correct
36 Partially correct 40 ms 5700 KB Partially correct - number of queries: 6356
37 Correct 25 ms 5700 KB Output is correct
38 Correct 17 ms 5700 KB Output is correct
39 Correct 40 ms 5700 KB Output is correct
40 Correct 13 ms 5700 KB Output is correct
41 Correct 39 ms 5700 KB Output is correct
42 Correct 37 ms 5700 KB Output is correct
43 Correct 42 ms 5700 KB Output is correct
44 Partially correct 35 ms 5704 KB Partially correct - number of queries: 5025
45 Partially correct 50 ms 5704 KB Partially correct - number of queries: 5060
46 Correct 13 ms 5704 KB Output is correct
47 Correct 53 ms 5704 KB Output is correct
48 Correct 36 ms 5704 KB Output is correct
49 Partially correct 92 ms 5704 KB Partially correct - number of queries: 7431
50 Correct 17 ms 5704 KB Output is correct
51 Partially correct 36 ms 5768 KB Partially correct - number of queries: 5042
52 Partially correct 116 ms 5768 KB Partially correct - number of queries: 7944
53 Correct 9 ms 5768 KB Output is correct
54 Correct 71 ms 5768 KB Output is correct
55 Correct 14 ms 5768 KB Output is correct
56 Correct 16 ms 5768 KB Output is correct
57 Correct 46 ms 5768 KB Output is correct
58 Correct 25 ms 5768 KB Output is correct
59 Correct 37 ms 5768 KB Output is correct
60 Correct 23 ms 5768 KB Output is correct
61 Correct 10 ms 5768 KB Output is correct
62 Correct 16 ms 5768 KB Output is correct
63 Correct 8 ms 5768 KB Output is correct
64 Correct 12 ms 5768 KB Output is correct
65 Correct 13 ms 5768 KB Output is correct
66 Correct 12 ms 5768 KB Output is correct
67 Correct 16 ms 5768 KB Output is correct
68 Correct 11 ms 5768 KB Output is correct
69 Correct 14 ms 5768 KB Output is correct
70 Correct 23 ms 5768 KB Output is correct
71 Partially correct 96 ms 5768 KB Partially correct - number of queries: 8551
72 Correct 19 ms 5768 KB Output is correct
73 Partially correct 90 ms 5768 KB Partially correct - number of queries: 8446
74 Partially correct 90 ms 5768 KB Partially correct - number of queries: 8491
75 Correct 12 ms 5768 KB Output is correct
76 Partially correct 63 ms 5768 KB Partially correct - number of queries: 7471
77 Partially correct 74 ms 5768 KB Partially correct - number of queries: 7678
78 Correct 18 ms 5768 KB Output is correct
79 Correct 34 ms 5768 KB Output is correct
80 Partially correct 71 ms 5768 KB Partially correct - number of queries: 7696
81 Partially correct 89 ms 5768 KB Partially correct - number of queries: 7673
82 Partially correct 71 ms 5768 KB Partially correct - number of queries: 7719
83 Correct 10 ms 5768 KB Output is correct
84 Partially correct 62 ms 5820 KB Partially correct - number of queries: 6491
85 Partially correct 81 ms 5820 KB Partially correct - number of queries: 7709
86 Incorrect 60 ms 5820 KB Incorrect
87 Halted 0 ms 0 KB -