답안 #289103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
289103 2020-09-02T11:01:34 Z wdjpng 커다란 상품 (IOI17_prize) C++17
92.77 / 100
67 ms 384 KB
#include "prize.h"
#include <bits/stdc++.h>
#define lint long long
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

int res = -1;
struct state{
	int i; int toLeft; int toRight;
	int sum(){
		return toLeft+toRight;
	}
};
void get(state l, state r){
	if(r.i-l.i<2){return;}
	if(r.toRight==l.toRight){return;}
	if(res>=0){return;}

	if(r.toRight-l.toRight==r.i-l.i-1)
	{
		for(int i = l.i+1; i < r.i; i++){
			vector<int>ans=ask(i);
			if(ans[0]+ans[1]==0) res = i;
		}
	} else
	{
		int mid = (l.i+r.i)/2;
		vector<int>tmp=ask(mid);
		state ansl = state({mid, tmp[0], tmp[1]});
		state ansr = ansl;

		while(ansl.sum()<l.sum()){
			if(ansl.sum()==0){res=ansl.i; return;}
			
			tmp=ask(ansl.i-1);
			ansl = state({ansl.i-1, tmp[0], tmp[1]});
		}

		while(ansr.sum()<l.sum()){
			if(ansr.sum()==0){res=ansr.i; return;}
			
			tmp=ask(ansr.i+1);
			ansr = state({ansr.i+1, tmp[0], tmp[1]});
		}

		get(l, ansl);
		get(ansr, r);
	}
}

state getState(int i){
	vector<int>tmp=ask(i);
	return state({i, tmp[0], tmp[1]});
}
int find_best(int n)
{
	if(n<5000&&false){
		rep(i, n){
			vector<int>ans=ask(i);
			if(ans[0]+ans[1]==0){return i;}
		}
	}

	state l = getState(0);
	state r = getState(n-1);
	
	int maxx=0;
	rep(i, 20){
		state s = getState(rand()%n);
		maxx=max(maxx, s.sum());
	}
	while(l.sum()<maxx){
		if(l.sum()==0){return l.i;}
		l=getState(l.i+1);
	}

	while(r.sum()<maxx){
		if(r.sum()==0){return r.i;}
		r=getState(r.i-1);
	}

	get(l,r);
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 7 ms 256 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 10 ms 256 KB Output is correct
16 Correct 39 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Partially correct 45 ms 256 KB Partially correct - number of queries: 5124
19 Correct 1 ms 256 KB Output is correct
20 Correct 7 ms 372 KB Output is correct
21 Correct 10 ms 376 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 22 ms 256 KB Output is correct
26 Correct 24 ms 256 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
28 Correct 49 ms 256 KB Output is correct
29 Correct 41 ms 256 KB Output is correct
30 Partially correct 27 ms 256 KB Partially correct - number of queries: 5094
31 Correct 1 ms 256 KB Output is correct
32 Correct 4 ms 288 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
34 Correct 21 ms 256 KB Output is correct
35 Correct 1 ms 376 KB Output is correct
36 Correct 9 ms 256 KB Output is correct
37 Correct 2 ms 256 KB Output is correct
38 Correct 1 ms 256 KB Output is correct
39 Correct 22 ms 256 KB Output is correct
40 Correct 45 ms 256 KB Output is correct
41 Correct 27 ms 256 KB Output is correct
42 Correct 29 ms 256 KB Output is correct
43 Correct 14 ms 384 KB Output is correct
44 Correct 19 ms 256 KB Output is correct
45 Correct 15 ms 256 KB Output is correct
46 Correct 1 ms 384 KB Output is correct
47 Correct 27 ms 256 KB Output is correct
48 Correct 34 ms 256 KB Output is correct
49 Correct 4 ms 256 KB Output is correct
50 Partially correct 60 ms 256 KB Partially correct - number of queries: 5118
51 Correct 15 ms 256 KB Output is correct
52 Correct 2 ms 256 KB Output is correct
53 Correct 2 ms 256 KB Output is correct
54 Correct 21 ms 256 KB Output is correct
55 Correct 1 ms 256 KB Output is correct
56 Partially correct 54 ms 256 KB Partially correct - number of queries: 5111
57 Correct 29 ms 256 KB Output is correct
58 Correct 31 ms 288 KB Output is correct
59 Correct 17 ms 256 KB Output is correct
60 Correct 24 ms 256 KB Output is correct
61 Correct 2 ms 256 KB Output is correct
62 Correct 1 ms 256 KB Output is correct
63 Correct 2 ms 256 KB Output is correct
64 Correct 2 ms 368 KB Output is correct
65 Correct 1 ms 256 KB Output is correct
66 Correct 1 ms 256 KB Output is correct
67 Correct 5 ms 256 KB Output is correct
68 Correct 6 ms 256 KB Output is correct
69 Correct 1 ms 256 KB Output is correct
70 Correct 4 ms 256 KB Output is correct
71 Partially correct 67 ms 256 KB Partially correct - number of queries: 5723
72 Correct 7 ms 256 KB Output is correct
73 Partially correct 62 ms 256 KB Partially correct - number of queries: 5646
74 Partially correct 66 ms 256 KB Partially correct - number of queries: 5679
75 Correct 3 ms 256 KB Output is correct
76 Correct 58 ms 256 KB Output is correct
77 Partially correct 61 ms 256 KB Partially correct - number of queries: 5184
78 Correct 6 ms 256 KB Output is correct
79 Correct 32 ms 256 KB Output is correct
80 Partially correct 60 ms 256 KB Partially correct - number of queries: 5183
81 Partially correct 40 ms 256 KB Partially correct - number of queries: 5217
82 Partially correct 60 ms 256 KB Partially correct - number of queries: 5106
83 Correct 2 ms 256 KB Output is correct
84 Correct 37 ms 256 KB Output is correct
85 Partially correct 46 ms 256 KB Partially correct - number of queries: 5210
86 Correct 7 ms 256 KB Output is correct
87 Correct 3 ms 256 KB Output is correct
88 Correct 5 ms 256 KB Output is correct
89 Correct 6 ms 256 KB Output is correct
90 Correct 2 ms 256 KB Output is correct
91 Correct 4 ms 256 KB Output is correct
92 Correct 1 ms 256 KB Output is correct
93 Correct 4 ms 256 KB Output is correct
94 Correct 4 ms 256 KB Output is correct
95 Correct 4 ms 256 KB Output is correct
96 Correct 4 ms 256 KB Output is correct
97 Correct 1 ms 256 KB Output is correct