답안 #54227

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54227 2018-07-02T21:05:42 Z radoslav11 커다란 상품 (IOI17_prize) C++14
90 / 100
106 ms 25524 KB
#include <bits/stdc++.h>
#include "prize.h"
//#include "Lgrader.cpp"

using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);

vector<int> memo[MAXN];
int Q = 0;

vector<int> query(int i) 
{
	if(memo[i].empty()) memo[i] = ask(i), Q++;
	if(Q == 10000) assert(false);
	return memo[i];
}

int find_best(int n) 
{
	int i = 0;
	while(i < n)
	{
		auto curr = query(i);
		if(curr[0] == 0 && curr[1] == 0)
			return i;

		int low = i, high = n - 1, mid, ret;
		
		for(int l = 0; low + (1 << l) < n; l++)
		{
			if(curr != query(low + (1 << l))) 
			{
				high = low + (1 << l);
				break;
			}
			
			low += (1 << l);
		}

		while(low <= high)
		{
			mid = (low + high) >> 1;
			if(curr == query(mid))
				low = mid + 1, ret = mid;
			else
				high = mid - 1;
		}

		i = ret + 1;
	}

	return -1;
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:51:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
   i = ret + 1;
   ~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 24952 KB Output is correct
2 Correct 23 ms 24952 KB Output is correct
3 Correct 22 ms 24964 KB Output is correct
4 Correct 22 ms 25024 KB Output is correct
5 Correct 22 ms 25080 KB Output is correct
6 Correct 23 ms 25080 KB Output is correct
7 Correct 23 ms 25080 KB Output is correct
8 Correct 23 ms 25080 KB Output is correct
9 Correct 25 ms 25148 KB Output is correct
10 Correct 23 ms 25148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 25148 KB Output is correct
2 Correct 26 ms 25148 KB Output is correct
3 Correct 23 ms 25148 KB Output is correct
4 Correct 26 ms 25148 KB Output is correct
5 Correct 25 ms 25148 KB Output is correct
6 Correct 22 ms 25148 KB Output is correct
7 Correct 23 ms 25148 KB Output is correct
8 Correct 22 ms 25148 KB Output is correct
9 Correct 29 ms 25148 KB Output is correct
10 Correct 25 ms 25148 KB Output is correct
11 Correct 25 ms 25148 KB Output is correct
12 Correct 22 ms 25148 KB Output is correct
13 Correct 28 ms 25148 KB Output is correct
14 Correct 24 ms 25148 KB Output is correct
15 Correct 30 ms 25224 KB Output is correct
16 Partially correct 55 ms 25388 KB Partially correct - number of queries: 6648
17 Correct 23 ms 25388 KB Output is correct
18 Partially correct 94 ms 25492 KB Partially correct - number of queries: 8025
19 Correct 26 ms 25492 KB Output is correct
20 Correct 44 ms 25492 KB Output is correct
21 Correct 46 ms 25492 KB Output is correct
22 Correct 27 ms 25492 KB Output is correct
23 Correct 22 ms 25492 KB Output is correct
24 Correct 23 ms 25492 KB Output is correct
25 Correct 54 ms 25492 KB Output is correct
26 Correct 68 ms 25492 KB Output is correct
27 Correct 24 ms 25492 KB Output is correct
28 Partially correct 55 ms 25500 KB Partially correct - number of queries: 7027
29 Partially correct 64 ms 25500 KB Partially correct - number of queries: 5455
30 Partially correct 80 ms 25500 KB Partially correct - number of queries: 7957
31 Correct 27 ms 25500 KB Output is correct
32 Correct 32 ms 25500 KB Output is correct
33 Correct 21 ms 25500 KB Output is correct
34 Correct 41 ms 25500 KB Output is correct
35 Correct 24 ms 25500 KB Output is correct
36 Correct 37 ms 25500 KB Output is correct
37 Correct 23 ms 25500 KB Output is correct
38 Correct 21 ms 25500 KB Output is correct
39 Correct 48 ms 25500 KB Output is correct
40 Partially correct 66 ms 25500 KB Partially correct - number of queries: 6802
41 Correct 63 ms 25500 KB Output is correct
42 Correct 62 ms 25500 KB Output is correct
43 Correct 51 ms 25500 KB Output is correct
44 Correct 45 ms 25500 KB Output is correct
45 Correct 41 ms 25500 KB Output is correct
46 Correct 22 ms 25500 KB Output is correct
47 Correct 54 ms 25500 KB Output is correct
48 Partially correct 56 ms 25500 KB Partially correct - number of queries: 5713
49 Correct 26 ms 25500 KB Output is correct
50 Partially correct 68 ms 25500 KB Partially correct - number of queries: 8025
51 Correct 45 ms 25500 KB Output is correct
52 Correct 23 ms 25500 KB Output is correct
53 Correct 23 ms 25500 KB Output is correct
54 Correct 45 ms 25500 KB Output is correct
55 Correct 23 ms 25500 KB Output is correct
56 Partially correct 89 ms 25500 KB Partially correct - number of queries: 8025
57 Partially correct 62 ms 25500 KB Partially correct - number of queries: 5628
58 Partially correct 65 ms 25500 KB Partially correct - number of queries: 5730
59 Correct 58 ms 25500 KB Output is correct
60 Correct 40 ms 25500 KB Output is correct
61 Correct 30 ms 25500 KB Output is correct
62 Correct 28 ms 25500 KB Output is correct
63 Correct 30 ms 25500 KB Output is correct
64 Correct 30 ms 25500 KB Output is correct
65 Correct 28 ms 25500 KB Output is correct
66 Correct 23 ms 25500 KB Output is correct
67 Correct 28 ms 25500 KB Output is correct
68 Correct 23 ms 25500 KB Output is correct
69 Correct 22 ms 25500 KB Output is correct
70 Correct 29 ms 25500 KB Output is correct
71 Partially correct 72 ms 25500 KB Partially correct - number of queries: 7701
72 Correct 32 ms 25500 KB Output is correct
73 Partially correct 92 ms 25500 KB Partially correct - number of queries: 7610
74 Partially correct 84 ms 25500 KB Partially correct - number of queries: 7649
75 Correct 24 ms 25500 KB Output is correct
76 Partially correct 76 ms 25500 KB Partially correct - number of queries: 6766
77 Partially correct 81 ms 25524 KB Partially correct - number of queries: 7673
78 Correct 31 ms 25524 KB Output is correct
79 Correct 48 ms 25524 KB Output is correct
80 Partially correct 68 ms 25524 KB Partially correct - number of queries: 7710
81 Partially correct 58 ms 25524 KB Partially correct - number of queries: 7623
82 Partially correct 84 ms 25524 KB Partially correct - number of queries: 7634
83 Correct 24 ms 25524 KB Output is correct
84 Partially correct 74 ms 25524 KB Partially correct - number of queries: 6533
85 Partially correct 106 ms 25524 KB Partially correct - number of queries: 7635
86 Correct 40 ms 25524 KB Output is correct
87 Correct 29 ms 25524 KB Output is correct
88 Correct 27 ms 25524 KB Output is correct
89 Correct 30 ms 25524 KB Output is correct
90 Correct 23 ms 25524 KB Output is correct
91 Correct 28 ms 25524 KB Output is correct
92 Correct 25 ms 25524 KB Output is correct
93 Correct 30 ms 25524 KB Output is correct
94 Correct 28 ms 25524 KB Output is correct
95 Correct 31 ms 25524 KB Output is correct
96 Correct 29 ms 25524 KB Output is correct
97 Correct 25 ms 25524 KB Output is correct