답안 #290740

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
290740 2020-09-04T11:51:40 Z abyyskit 커다란 상품 (IOI17_prize) C++14
94.99 / 100
66 ms 512 KB
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for(int i = x; i < y; ++i)
#define pb push_back

int ANS;
int SCORE;

void findAll(int l, int r, int L, int R){
	//cout << "findALL(" << l << ", " << r << ")\n";
	if (l == r) return;
	int mid = (l + r)/2;
	vector<int> tmp = ask(mid);
	if (tmp[0] + tmp[1] == 0){
		ANS = mid;
		return;
	}
	if (tmp[0] + tmp[1] == SCORE){
		if (tmp[0] - L != 0){
			findAll(l, mid, L, tmp[1]);
		}
		if (R - tmp[1] != 0){
			findAll(mid + 1, r, tmp[0], R);
		}
		return;
	}
	int rp = l;
	int rL;
	int rR;
	FOR(i, mid + 1, r){
		tmp = ask(i);
		if (tmp[0] + tmp[1] == 0){
			ANS = i;
			return;
		}
		if (tmp[0] + tmp[1] == SCORE){
			rp = i;
			rL = tmp[0];
			rR = tmp[1];
			break;
		}
	}
	int lp = r;
	int lL;
	int lR;
	for (int i = mid - 1; i >= l; --i){
		tmp = ask(i);
		if (tmp[0] + tmp[1] == 0){
			ANS = i;
			return;
		}
		if (tmp[0] + tmp[1] == SCORE){
			lp = i;
			lL = tmp[0];
			lR = tmp[1];
			break;
		}
	}
	if (rp != l){
		findAll(rp + 1, r, rL, R);
	}
	if (lp != r){
		findAll(l, lp, L, lR);
	}

}

int find_best(int n) {
	int score = 0;
	FOR(i, 0, min(476, n)){
		vector<int> tmp = ask(i);
		score = max(score, tmp[0] + tmp[1]);
		if (tmp[0] + tmp[1] == 0){
			return i;
		}
	}
	SCORE = score;
	findAll(0, n, 0, 0);
	return ANS;
}

Compilation message

prize.cpp: In function 'void findAll(int, int, int, int)':
prize.cpp:30:6: warning: variable 'rR' set but not used [-Wunused-but-set-variable]
   30 |  int rR;
      |      ^~
prize.cpp:45:6: warning: variable 'lL' set but not used [-Wunused-but-set-variable]
   45 |  int lL;
      |      ^~
prize.cpp:64:10: warning: 'lR' may be used uninitialized in this function [-Wmaybe-uninitialized]
   64 |   findAll(l, lp, L, lR);
      |   ~~~~~~~^~~~~~~~~~~~~~
prize.cpp:61:10: warning: 'rL' may be used uninitialized in this function [-Wmaybe-uninitialized]
   61 |   findAll(rp + 1, r, rL, R);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 7 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 7 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 7 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 8 ms 256 KB Output is correct
12 Correct 9 ms 256 KB Output is correct
13 Correct 7 ms 256 KB Output is correct
14 Correct 13 ms 384 KB Output is correct
15 Partially correct 40 ms 256 KB Partially correct - number of queries: 5162
16 Partially correct 45 ms 256 KB Partially correct - number of queries: 5361
17 Correct 5 ms 256 KB Output is correct
18 Partially correct 45 ms 256 KB Partially correct - number of queries: 5434
19 Correct 6 ms 256 KB Output is correct
20 Correct 22 ms 256 KB Output is correct
21 Partially correct 42 ms 256 KB Partially correct - number of queries: 5321
22 Correct 37 ms 256 KB Output is correct
23 Correct 8 ms 256 KB Output is correct
24 Correct 10 ms 256 KB Output is correct
25 Correct 41 ms 256 KB Output is correct
26 Correct 60 ms 256 KB Output is correct
27 Correct 8 ms 256 KB Output is correct
28 Correct 41 ms 256 KB Output is correct
29 Correct 51 ms 256 KB Output is correct
30 Partially correct 64 ms 256 KB Partially correct - number of queries: 5369
31 Correct 5 ms 256 KB Output is correct
32 Correct 9 ms 256 KB Output is correct
33 Correct 0 ms 256 KB Output is correct
34 Partially correct 27 ms 376 KB Partially correct - number of queries: 5384
35 Correct 9 ms 256 KB Output is correct
36 Partially correct 66 ms 256 KB Partially correct - number of queries: 5402
37 Correct 6 ms 256 KB Output is correct
38 Correct 8 ms 256 KB Output is correct
39 Partially correct 41 ms 256 KB Partially correct - number of queries: 5378
40 Correct 24 ms 376 KB Output is correct
41 Partially correct 54 ms 256 KB Partially correct - number of queries: 5395
42 Partially correct 43 ms 256 KB Partially correct - number of queries: 5395
43 Partially correct 36 ms 256 KB Partially correct - number of queries: 5252
44 Partially correct 60 ms 256 KB Partially correct - number of queries: 5394
45 Correct 59 ms 256 KB Output is correct
46 Correct 5 ms 256 KB Output is correct
47 Partially correct 32 ms 256 KB Partially correct - number of queries: 5074
48 Partially correct 51 ms 256 KB Partially correct - number of queries: 5394
49 Partially correct 46 ms 256 KB Partially correct - number of queries: 5448
50 Partially correct 64 ms 256 KB Partially correct - number of queries: 5382
51 Partially correct 59 ms 384 KB Partially correct - number of queries: 5388
52 Partially correct 62 ms 256 KB Partially correct - number of queries: 5395
53 Correct 6 ms 256 KB Output is correct
54 Partially correct 62 ms 256 KB Partially correct - number of queries: 5348
55 Correct 5 ms 256 KB Output is correct
56 Partially correct 50 ms 256 KB Partially correct - number of queries: 5403
57 Partially correct 45 ms 256 KB Partially correct - number of queries: 5390
58 Partially correct 28 ms 384 KB Partially correct - number of queries: 5371
59 Partially correct 33 ms 376 KB Partially correct - number of queries: 5377
60 Partially correct 28 ms 384 KB Partially correct - number of queries: 5359
61 Correct 8 ms 256 KB Output is correct
62 Correct 4 ms 376 KB Output is correct
63 Correct 7 ms 376 KB Output is correct
64 Correct 6 ms 256 KB Output is correct
65 Correct 7 ms 256 KB Output is correct
66 Correct 9 ms 256 KB Output is correct
67 Correct 10 ms 256 KB Output is correct
68 Correct 5 ms 256 KB Output is correct
69 Correct 9 ms 256 KB Output is correct
70 Correct 10 ms 256 KB Output is correct
71 Partially correct 62 ms 256 KB Partially correct - number of queries: 5235
72 Correct 10 ms 256 KB Output is correct
73 Partially correct 40 ms 256 KB Partially correct - number of queries: 5172
74 Partially correct 53 ms 256 KB Partially correct - number of queries: 5199
75 Correct 6 ms 256 KB Output is correct
76 Correct 41 ms 256 KB Output is correct
77 Partially correct 56 ms 256 KB Partially correct - number of queries: 5493
78 Correct 9 ms 256 KB Output is correct
79 Correct 25 ms 256 KB Output is correct
80 Partially correct 29 ms 372 KB Partially correct - number of queries: 5501
81 Partially correct 50 ms 256 KB Partially correct - number of queries: 5453
82 Partially correct 47 ms 256 KB Partially correct - number of queries: 5445
83 Correct 7 ms 256 KB Output is correct
84 Correct 45 ms 256 KB Output is correct
85 Partially correct 43 ms 256 KB Partially correct - number of queries: 5464
86 Correct 9 ms 256 KB Output is correct
87 Correct 4 ms 288 KB Output is correct
88 Correct 9 ms 256 KB Output is correct
89 Correct 10 ms 512 KB Output is correct
90 Correct 3 ms 256 KB Output is correct
91 Correct 9 ms 256 KB Output is correct
92 Correct 12 ms 256 KB Output is correct
93 Correct 12 ms 256 KB Output is correct
94 Correct 11 ms 256 KB Output is correct
95 Correct 9 ms 256 KB Output is correct
96 Correct 14 ms 256 KB Output is correct
97 Correct 11 ms 256 KB Output is correct