답안 #286373

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
286373 2020-08-30T10:38:44 Z Atill83 커다란 상품 (IOI17_prize) C++14
97.93 / 100
68 ms 5496 KB
	#include "prize.h"
	#include <bits/stdc++.h>
	using namespace std;
	const int MAXN = (int) 2e5 + 5;
	vector<int> asked[MAXN];
	vector<int> kuc;
	bool kc[MAXN];
	vector<int> aski(int i){
		if(!asked[i].empty()) return asked[i];
		return asked[i] = ask(i);
	}




	int find_best(int n) {
		int top = 0;
		mt19937 gen(time(NULL));
		for(int i = 0; i < 470; i++){
			int u = gen() % n;
			vector<int> cev = aski(u);
			if(cev[0] + cev[1] == 0) return u;
			top = max(top, cev[0] + cev[1]);
		}
		//assert(top <= 600);


		while(true){
			int sz1 = kuc.size();
			int l = 0, r = n - 1;
			while(l < r){
				int m = (l + r) / 2;
				while(kc[m] && m > l) m--;
				if(m == l && kc[m]){
					m = (l + r) / 2;
					while(m < r && kc[m]) m++;
				}
				vector<int> cev = aski(m);
				if(cev[0] + cev[1] != top){
					l = m;
					r = m;
				}else{
					cev[0] -= lower_bound(kuc.begin(), kuc.end(), m) - kuc.begin();
					if(cev[0] > 0){
						r = m - 1;
					}else{
						l = m + 1;
					}
				}
			}
			vector<int> cev = aski(l);
			//assert(cev[0] + cev[1] != top);
			if(cev[0] == 0 && cev[1] == 0){
				return l;
			}else {
				//assert(kc[l] != 1);
				kuc.push_back(l);
				int idx = kuc.size() - 1;
				while(idx != 0 && kuc[idx - 1] > kuc[idx]){
					idx--;
					swap(kuc[idx], kuc[idx + 1]);
				}
				kc[l] = 1;
			}
			//assert(kuc.size() != sz1);
		}
		return -1;
	}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:29:8: warning: unused variable 'sz1' [-Wunused-variable]
   29 |    int sz1 = kuc.size();
      |        ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 5084 KB Output is correct
2 Correct 9 ms 4992 KB Output is correct
3 Correct 6 ms 5088 KB Output is correct
4 Correct 8 ms 4992 KB Output is correct
5 Correct 9 ms 4992 KB Output is correct
6 Correct 10 ms 4992 KB Output is correct
7 Correct 6 ms 5088 KB Output is correct
8 Correct 9 ms 5024 KB Output is correct
9 Correct 8 ms 4992 KB Output is correct
10 Correct 8 ms 4992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 4992 KB Output is correct
2 Correct 9 ms 4992 KB Output is correct
3 Correct 7 ms 5128 KB Output is correct
4 Correct 7 ms 4992 KB Output is correct
5 Correct 9 ms 4992 KB Output is correct
6 Correct 8 ms 4992 KB Output is correct
7 Correct 10 ms 4992 KB Output is correct
8 Correct 10 ms 4992 KB Output is correct
9 Correct 10 ms 5088 KB Output is correct
10 Correct 10 ms 4992 KB Output is correct
11 Correct 7 ms 5160 KB Output is correct
12 Correct 10 ms 4992 KB Output is correct
13 Correct 14 ms 5112 KB Output is correct
14 Correct 9 ms 4992 KB Output is correct
15 Correct 11 ms 5124 KB Output is correct
16 Correct 41 ms 5240 KB Output is correct
17 Correct 8 ms 4992 KB Output is correct
18 Correct 48 ms 5372 KB Output is correct
19 Correct 10 ms 4992 KB Output is correct
20 Correct 16 ms 5120 KB Output is correct
21 Correct 21 ms 5112 KB Output is correct
22 Correct 12 ms 5120 KB Output is correct
23 Correct 8 ms 4992 KB Output is correct
24 Correct 8 ms 4992 KB Output is correct
25 Correct 17 ms 5228 KB Output is correct
26 Correct 34 ms 5240 KB Output is correct
27 Correct 9 ms 4992 KB Output is correct
28 Correct 51 ms 5368 KB Output is correct
29 Correct 31 ms 5368 KB Output is correct
30 Correct 46 ms 5368 KB Output is correct
31 Correct 10 ms 4992 KB Output is correct
32 Correct 9 ms 5244 KB Output is correct
33 Correct 4 ms 4992 KB Output is correct
34 Correct 26 ms 5112 KB Output is correct
35 Correct 9 ms 5112 KB Output is correct
36 Correct 17 ms 5112 KB Output is correct
37 Correct 10 ms 4992 KB Output is correct
38 Correct 8 ms 5152 KB Output is correct
39 Correct 29 ms 5112 KB Output is correct
40 Correct 50 ms 5312 KB Output is correct
41 Correct 37 ms 5388 KB Output is correct
42 Correct 40 ms 5212 KB Output is correct
43 Correct 30 ms 5240 KB Output is correct
44 Correct 30 ms 5100 KB Output is correct
45 Correct 20 ms 5112 KB Output is correct
46 Correct 9 ms 5084 KB Output is correct
47 Correct 27 ms 5240 KB Output is correct
48 Correct 44 ms 5240 KB Output is correct
49 Correct 8 ms 5152 KB Output is correct
50 Correct 58 ms 5440 KB Output is correct
51 Correct 28 ms 5112 KB Output is correct
52 Correct 10 ms 4992 KB Output is correct
53 Correct 10 ms 5152 KB Output is correct
54 Correct 24 ms 5152 KB Output is correct
55 Correct 6 ms 5140 KB Output is correct
56 Correct 67 ms 5368 KB Output is correct
57 Correct 34 ms 5244 KB Output is correct
58 Correct 28 ms 5424 KB Output is correct
59 Correct 32 ms 5240 KB Output is correct
60 Correct 31 ms 5288 KB Output is correct
61 Correct 10 ms 5112 KB Output is correct
62 Correct 10 ms 4992 KB Output is correct
63 Correct 11 ms 5112 KB Output is correct
64 Correct 9 ms 4992 KB Output is correct
65 Correct 10 ms 4992 KB Output is correct
66 Correct 15 ms 4992 KB Output is correct
67 Correct 9 ms 4992 KB Output is correct
68 Correct 13 ms 4992 KB Output is correct
69 Correct 11 ms 5120 KB Output is correct
70 Correct 11 ms 4992 KB Output is correct
71 Partially correct 64 ms 5368 KB Partially correct - number of queries: 5207
72 Correct 13 ms 5112 KB Output is correct
73 Partially correct 65 ms 5496 KB Partially correct - number of queries: 5148
74 Partially correct 68 ms 5368 KB Partially correct - number of queries: 5175
75 Correct 11 ms 5120 KB Output is correct
76 Correct 44 ms 5368 KB Output is correct
77 Correct 42 ms 5372 KB Output is correct
78 Correct 11 ms 5120 KB Output is correct
79 Correct 29 ms 5368 KB Output is correct
80 Correct 47 ms 5368 KB Output is correct
81 Correct 46 ms 5368 KB Output is correct
82 Correct 59 ms 5368 KB Output is correct
83 Correct 10 ms 5120 KB Output is correct
84 Correct 42 ms 5368 KB Output is correct
85 Correct 48 ms 5368 KB Output is correct
86 Correct 32 ms 5240 KB Output is correct
87 Correct 13 ms 5248 KB Output is correct
88 Correct 26 ms 5496 KB Output is correct
89 Correct 24 ms 5240 KB Output is correct
90 Correct 10 ms 5120 KB Output is correct
91 Correct 22 ms 5240 KB Output is correct
92 Correct 19 ms 5120 KB Output is correct
93 Correct 47 ms 5240 KB Output is correct
94 Correct 34 ms 5404 KB Output is correct
95 Correct 50 ms 5368 KB Output is correct
96 Correct 40 ms 5368 KB Output is correct
97 Correct 46 ms 5368 KB Output is correct