답안 #785711

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
785711 2023-07-17T13:29:52 Z QwertyPi 커다란 상품 (IOI17_prize) C++14
97.54 / 100
48 ms 1060 KB
#include "prize.h"
#include <bits/stdc++.h>

using namespace std;

map<int, vector<int>> M, Li;
vector<int> self_ask(int i){
	if(!M.count(i)) M[i] = ask(i); vector<int> r = M[i];
	Li[r[0] + r[1]].push_back(i);
	return r;
}

vector<int> b;

bool failed = false, un = true;
int cc;
void solve(int l, int r, int lc, int rc){
	if(l > r || lc == rc) return;
	int L = (l + r) / 2, R = (l + r) / 2 + 1, F = 0;
	int c; vector<int> a;
	while(true){
		c = F ? R++ : L--; F ^= 1;
		a = self_ask(c);
		if(un || a[0] + a[1] > cc){
			failed = true; un = false; cc = a[0] + a[1];
			return;
		}
		if(a[0] + a[1] == cc || R - L - 1 == rc - lc){
			break;
		}
	}
	if(c == L + 1){
		solve(l, L, lc, a[0]); if(failed) return;
		solve(R, r, a[0] + (R - L - 2), rc); if(failed) return;
	}else{
		solve(l, L, lc, a[0] - (R - L - 2)); if(failed) return;
		solve(R, r, a[0], rc); if(failed) return;
	}
}

int find_best(int n) {
	cc = n;
	do{
		failed = false;
		solve(0, n - 1, 0, cc);
	}while(failed);
	for(auto [i, p] : M){
		if(p[0] + p[1] == 0){
			return i;
		}
	}
	return -1; 
}

Compilation message

prize.cpp: In function 'std::vector<int> self_ask(int)':
prize.cpp:8:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    8 |  if(!M.count(i)) M[i] = ask(i); vector<int> r = M[i];
      |  ^~
prize.cpp:8:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    8 |  if(!M.count(i)) M[i] = ask(i); vector<int> r = M[i];
      |                                 ^~~~~~
prize.cpp: In function 'int find_best(int)':
prize.cpp:47:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   47 |  for(auto [i, p] : M){
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 292 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 296 KB Output is correct
9 Correct 1 ms 288 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 292 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 0 ms 296 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 4 ms 336 KB Output is correct
12 Correct 4 ms 336 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 10 ms 380 KB Output is correct
15 Correct 29 ms 796 KB Output is correct
16 Partially correct 37 ms 788 KB Partially correct - number of queries: 5041
17 Partially correct 43 ms 828 KB Partially correct - number of queries: 5060
18 Partially correct 24 ms 840 KB Partially correct - number of queries: 5032
19 Correct 32 ms 740 KB Output is correct
20 Correct 29 ms 684 KB Output is correct
21 Partially correct 20 ms 848 KB Partially correct - number of queries: 5010
22 Correct 24 ms 596 KB Output is correct
23 Correct 1 ms 208 KB Output is correct
24 Correct 4 ms 288 KB Output is correct
25 Correct 32 ms 744 KB Output is correct
26 Correct 42 ms 796 KB Output is correct
27 Correct 1 ms 288 KB Output is correct
28 Correct 18 ms 808 KB Output is correct
29 Correct 26 ms 664 KB Output is correct
30 Partially correct 36 ms 828 KB Partially correct - number of queries: 5028
31 Partially correct 25 ms 836 KB Partially correct - number of queries: 5021
32 Correct 4 ms 292 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Partially correct 34 ms 832 KB Partially correct - number of queries: 5031
35 Correct 1 ms 340 KB Output is correct
36 Partially correct 46 ms 736 KB Partially correct - number of queries: 5060
37 Correct 3 ms 336 KB Output is correct
38 Correct 2 ms 296 KB Output is correct
39 Partially correct 41 ms 832 KB Partially correct - number of queries: 5069
40 Correct 18 ms 764 KB Output is correct
41 Partially correct 34 ms 816 KB Partially correct - number of queries: 5096
42 Partially correct 48 ms 944 KB Partially correct - number of queries: 5096
43 Correct 20 ms 848 KB Output is correct
44 Partially correct 25 ms 856 KB Partially correct - number of queries: 5053
45 Correct 26 ms 796 KB Output is correct
46 Partially correct 20 ms 836 KB Partially correct - number of queries: 5063
47 Correct 37 ms 752 KB Output is correct
48 Partially correct 40 ms 828 KB Partially correct - number of queries: 5051
49 Partially correct 38 ms 860 KB Partially correct - number of queries: 5076
50 Partially correct 35 ms 772 KB Partially correct - number of queries: 5057
51 Partially correct 25 ms 828 KB Partially correct - number of queries: 5058
52 Partially correct 47 ms 808 KB Partially correct - number of queries: 5068
53 Correct 1 ms 300 KB Output is correct
54 Partially correct 42 ms 804 KB Partially correct - number of queries: 5014
55 Partially correct 21 ms 796 KB Partially correct - number of queries: 5065
56 Partially correct 34 ms 840 KB Partially correct - number of queries: 5058
57 Partially correct 41 ms 760 KB Partially correct - number of queries: 5006
58 Partially correct 33 ms 876 KB Partially correct - number of queries: 5065
59 Partially correct 44 ms 844 KB Partially correct - number of queries: 5094
60 Partially correct 34 ms 832 KB Partially correct - number of queries: 5035
61 Correct 2 ms 288 KB Output is correct
62 Correct 1 ms 296 KB Output is correct
63 Correct 2 ms 292 KB Output is correct
64 Correct 2 ms 296 KB Output is correct
65 Correct 1 ms 304 KB Output is correct
66 Correct 3 ms 288 KB Output is correct
67 Correct 2 ms 332 KB Output is correct
68 Correct 2 ms 376 KB Output is correct
69 Correct 3 ms 288 KB Output is correct
70 Correct 2 ms 316 KB Output is correct
71 Correct 24 ms 788 KB Output is correct
72 Correct 3 ms 340 KB Output is correct
73 Correct 30 ms 716 KB Output is correct
74 Correct 30 ms 780 KB Output is correct
75 Correct 2 ms 208 KB Output is correct
76 Correct 30 ms 724 KB Output is correct
77 Partially correct 38 ms 840 KB Partially correct - number of queries: 5214
78 Correct 5 ms 336 KB Output is correct
79 Correct 25 ms 484 KB Output is correct
80 Partially correct 45 ms 860 KB Partially correct - number of queries: 5246
81 Partially correct 36 ms 1060 KB Partially correct - number of queries: 5210
82 Partially correct 44 ms 796 KB Partially correct - number of queries: 5201
83 Correct 1 ms 208 KB Output is correct
84 Correct 26 ms 748 KB Output is correct
85 Partially correct 47 ms 868 KB Partially correct - number of queries: 5180
86 Correct 6 ms 332 KB Output is correct
87 Correct 1 ms 208 KB Output is correct
88 Correct 4 ms 336 KB Output is correct
89 Correct 5 ms 340 KB Output is correct
90 Correct 1 ms 208 KB Output is correct
91 Correct 3 ms 304 KB Output is correct
92 Correct 5 ms 336 KB Output is correct
93 Correct 4 ms 336 KB Output is correct
94 Correct 3 ms 336 KB Output is correct
95 Correct 2 ms 336 KB Output is correct
96 Correct 3 ms 208 KB Output is correct
97 Correct 1 ms 304 KB Output is correct