Submission #169927

# Submission time Handle Problem Language Result Execution time Memory
169927 2019-12-23T09:38:03 Z dennisstar The Big Prize (IOI17_prize) C++11
100 / 100
53 ms 2204 KB
#include "prize.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef vector<int> vim;


int N;
set<pair<int, pii> > S[10]; int val[10], tp;

int ans, fl, chk[200010], ar[200010];

int f(int v) {
	for (int i=0; i<tp; i++) if (val[i]==v) return i;
	val[tp]=v; return tp++;
}

void myfind(int s, int e) {
	if (s>e) return ;
	int md=(s+e)/2;
	if (chk[md]) return ;
	chk[md]=1;
	vim res=ask(md);
	ar[md]=res[0]+res[1];
	if (res[0]==0&&res[1]==0) {
		ans=md;
		fl=1;
		return ;
	}
	int ind=f(ar[md]);
	S[ind].insert({md, make_pair(res[0], res[1])});

	auto it=S[ind].find({md, make_pair(res[0], res[1])});
	pair<int, pii> p=(*it), pr, ne;
	if (it==S[ind].begin()) pr={-1, make_pair(0, ar[md])};
	else pr=*prev(it);
	if (next(it)==S[ind].end()) ne={N, make_pair(ar[md], 0)};
	else ne=*next(it);
	if (pr.se.fi!=p.se.fi) myfind(max(s, pr.fi+1), p.fi-1);
	if (fl) return ;
	if (p.se.fi!=ne.se.fi) myfind(p.fi+1, min(e, ne.fi-1));
}

int find_best(int n) {
	N=n;
	myfind(0, n-1);
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 388 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 404 KB Output is correct
5 Correct 2 ms 388 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 248 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 388 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 312 KB Output is correct
9 Correct 2 ms 320 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Correct 4 ms 636 KB Output is correct
12 Correct 2 ms 316 KB Output is correct
13 Correct 9 ms 1272 KB Output is correct
14 Correct 3 ms 404 KB Output is correct
15 Correct 8 ms 504 KB Output is correct
16 Correct 39 ms 1784 KB Output is correct
17 Correct 2 ms 400 KB Output is correct
18 Correct 30 ms 2196 KB Output is correct
19 Correct 2 ms 388 KB Output is correct
20 Correct 19 ms 760 KB Output is correct
21 Correct 21 ms 936 KB Output is correct
22 Correct 4 ms 560 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 30 ms 1272 KB Output is correct
26 Correct 24 ms 1296 KB Output is correct
27 Correct 3 ms 440 KB Output is correct
28 Correct 40 ms 1948 KB Output is correct
29 Correct 41 ms 1760 KB Output is correct
30 Correct 33 ms 2160 KB Output is correct
31 Correct 2 ms 308 KB Output is correct
32 Correct 6 ms 948 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 14 ms 888 KB Output is correct
35 Correct 3 ms 632 KB Output is correct
36 Correct 12 ms 760 KB Output is correct
37 Correct 3 ms 476 KB Output is correct
38 Correct 2 ms 312 KB Output is correct
39 Correct 20 ms 1144 KB Output is correct
40 Correct 43 ms 2040 KB Output is correct
41 Correct 32 ms 1400 KB Output is correct
42 Correct 29 ms 1404 KB Output is correct
43 Correct 27 ms 1228 KB Output is correct
44 Correct 20 ms 948 KB Output is correct
45 Correct 9 ms 904 KB Output is correct
46 Correct 2 ms 388 KB Output is correct
47 Correct 26 ms 1016 KB Output is correct
48 Correct 43 ms 1656 KB Output is correct
49 Correct 4 ms 528 KB Output is correct
50 Correct 41 ms 2144 KB Output is correct
51 Correct 22 ms 1016 KB Output is correct
52 Correct 2 ms 376 KB Output is correct
53 Correct 3 ms 632 KB Output is correct
54 Correct 22 ms 1064 KB Output is correct
55 Correct 2 ms 376 KB Output is correct
56 Correct 27 ms 2204 KB Output is correct
57 Correct 36 ms 1528 KB Output is correct
58 Correct 36 ms 1616 KB Output is correct
59 Correct 26 ms 1348 KB Output is correct
60 Correct 15 ms 1324 KB Output is correct
61 Correct 4 ms 632 KB Output is correct
62 Correct 2 ms 376 KB Output is correct
63 Correct 4 ms 564 KB Output is correct
64 Correct 3 ms 436 KB Output is correct
65 Correct 2 ms 376 KB Output is correct
66 Correct 2 ms 376 KB Output is correct
67 Correct 2 ms 376 KB Output is correct
68 Correct 2 ms 376 KB Output is correct
69 Correct 2 ms 392 KB Output is correct
70 Correct 2 ms 296 KB Output is correct
71 Correct 53 ms 2168 KB Output is correct
72 Correct 8 ms 1292 KB Output is correct
73 Correct 47 ms 2104 KB Output is correct
74 Correct 53 ms 2168 KB Output is correct
75 Correct 4 ms 632 KB Output is correct
76 Correct 50 ms 2040 KB Output is correct
77 Correct 52 ms 2108 KB Output is correct
78 Correct 7 ms 1272 KB Output is correct
79 Correct 27 ms 2040 KB Output is correct
80 Correct 49 ms 2044 KB Output is correct
81 Correct 38 ms 2168 KB Output is correct
82 Correct 28 ms 2196 KB Output is correct
83 Correct 4 ms 760 KB Output is correct
84 Correct 34 ms 2088 KB Output is correct
85 Correct 28 ms 2180 KB Output is correct
86 Correct 8 ms 1064 KB Output is correct
87 Correct 5 ms 632 KB Output is correct
88 Correct 9 ms 1016 KB Output is correct
89 Correct 8 ms 1016 KB Output is correct
90 Correct 3 ms 644 KB Output is correct
91 Correct 4 ms 904 KB Output is correct
92 Correct 2 ms 380 KB Output is correct
93 Correct 5 ms 760 KB Output is correct
94 Correct 7 ms 888 KB Output is correct
95 Correct 5 ms 888 KB Output is correct
96 Correct 5 ms 888 KB Output is correct
97 Correct 2 ms 376 KB Output is correct