답안 #73130

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73130 2018-08-27T18:27:01 Z aleksam 커다란 상품 (IOI17_prize) C++14
90 / 100
98 ms 5772 KB
#include "prize.h"

#include <bits/stdc++.h>
#define MAX_N 200000
using namespace std;

int N;
bool mark[MAX_N];
vector<int> resp[MAX_N];
int worst=MAX_N;

vector<int> aksp(int x){
	if(!mark[x]){
		resp[x]=ask(x);
		mark[x]=1;
	}
	return resp[x];
}

int left(int x){
	if(!mark[x]){
		resp[x]=ask(x);
		mark[x]=1;
	}
	return resp[x][0];
}

int right(int x){
	if(!mark[x]){
		resp[x]=ask(x);
		mark[x]=1;
	}
	return resp[x][1];
}

int weight(int x){//printf("weight(%d)\n", x);
	return left(x)+right(x);
}

int find(int l, int r){
	//printf("find(%d, %d)\n", l, r);
	if(l>=r && l>=0 && l<N){
		if(weight(l)==0){
			return l;
		}
		return -1;
	}
	if(weight(l)==0)return l;
	if(weight(r)==0)return r;
	if(weight(l)!=weight(r)){
		if(weight(l)>weight(r))return find(l, r-1);
		else return find(l+1, r);
	}
	if(left(r)==left(l))return -1;
	int mid=(l+r)/2;
	int rl=-1, rr=-1;
	if(weight(mid)==0)return mid;
	rl=find(l, mid);
	if(rl>-1)return rl;
	else return find(mid+1, r);
}

int easy_solve(int n) {
	for(int i = 0; i < n; i++) {
		std::vector<int> res = ask(i);
		if(res[0] + res[1] == 0)
			return i;
	}
	return 0;
}

void find_worst(){
	for(int i=0; i<450; ++i){//Ad hoc
		if(left(i)+right(i)<worst){
			worst=left(i)+right(i);
			if(2*worst>N){
				return;
			}
		}
	}
}

int find_best(int n) {
	
	N=n;
	//if(N<5005)return easy_solve(N);
	//find_worst();
	
	return find(0, N-1);
}

Compilation message

prize.cpp: In function 'int find(int, int)':
prize.cpp:56:13: warning: unused variable 'rr' [-Wunused-variable]
  int rl=-1, rr=-1;
             ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 8 ms 5176 KB Output is correct
3 Correct 6 ms 5176 KB Output is correct
4 Correct 7 ms 5176 KB Output is correct
5 Correct 7 ms 5176 KB Output is correct
6 Correct 6 ms 5176 KB Output is correct
7 Correct 6 ms 5176 KB Output is correct
8 Correct 7 ms 5260 KB Output is correct
9 Correct 7 ms 5260 KB Output is correct
10 Correct 7 ms 5260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5260 KB Output is correct
2 Correct 6 ms 5260 KB Output is correct
3 Correct 7 ms 5260 KB Output is correct
4 Correct 8 ms 5260 KB Output is correct
5 Correct 6 ms 5260 KB Output is correct
6 Correct 7 ms 5260 KB Output is correct
7 Correct 6 ms 5260 KB Output is correct
8 Correct 6 ms 5260 KB Output is correct
9 Correct 6 ms 5260 KB Output is correct
10 Correct 6 ms 5260 KB Output is correct
11 Correct 14 ms 5260 KB Output is correct
12 Correct 6 ms 5264 KB Output is correct
13 Correct 12 ms 5436 KB Output is correct
14 Correct 10 ms 5436 KB Output is correct
15 Correct 16 ms 5436 KB Output is correct
16 Partially correct 60 ms 5688 KB Partially correct - number of queries: 6196
17 Correct 6 ms 5688 KB Output is correct
18 Partially correct 36 ms 5688 KB Partially correct - number of queries: 7516
19 Correct 6 ms 5688 KB Output is correct
20 Correct 21 ms 5688 KB Output is correct
21 Correct 45 ms 5688 KB Output is correct
22 Correct 12 ms 5688 KB Output is correct
23 Correct 6 ms 5688 KB Output is correct
24 Correct 8 ms 5688 KB Output is correct
25 Correct 63 ms 5688 KB Output is correct
26 Correct 57 ms 5688 KB Output is correct
27 Correct 10 ms 5688 KB Output is correct
28 Partially correct 88 ms 5688 KB Partially correct - number of queries: 6453
29 Correct 45 ms 5688 KB Output is correct
30 Partially correct 61 ms 5764 KB Partially correct - number of queries: 7471
31 Correct 9 ms 5764 KB Output is correct
32 Correct 19 ms 5764 KB Output is correct
33 Correct 7 ms 5764 KB Output is correct
34 Correct 15 ms 5764 KB Output is correct
35 Correct 8 ms 5764 KB Output is correct
36 Correct 23 ms 5764 KB Output is correct
37 Correct 11 ms 5764 KB Output is correct
38 Correct 10 ms 5764 KB Output is correct
39 Correct 40 ms 5764 KB Output is correct
40 Partially correct 59 ms 5764 KB Partially correct - number of queries: 6508
41 Correct 54 ms 5764 KB Output is correct
42 Correct 61 ms 5764 KB Output is correct
43 Correct 36 ms 5764 KB Output is correct
44 Correct 44 ms 5764 KB Output is correct
45 Correct 37 ms 5764 KB Output is correct
46 Correct 6 ms 5764 KB Output is correct
47 Correct 42 ms 5764 KB Output is correct
48 Partially correct 72 ms 5764 KB Partially correct - number of queries: 5340
49 Correct 18 ms 5764 KB Output is correct
50 Partially correct 74 ms 5764 KB Partially correct - number of queries: 7474
51 Correct 40 ms 5764 KB Output is correct
52 Correct 8 ms 5764 KB Output is correct
53 Correct 8 ms 5764 KB Output is correct
54 Correct 44 ms 5764 KB Output is correct
55 Correct 7 ms 5764 KB Output is correct
56 Partially correct 87 ms 5764 KB Partially correct - number of queries: 7562
57 Partially correct 70 ms 5764 KB Partially correct - number of queries: 5315
58 Partially correct 80 ms 5764 KB Partially correct - number of queries: 5374
59 Correct 23 ms 5764 KB Output is correct
60 Correct 49 ms 5764 KB Output is correct
61 Correct 8 ms 5764 KB Output is correct
62 Correct 7 ms 5764 KB Output is correct
63 Correct 12 ms 5764 KB Output is correct
64 Correct 8 ms 5764 KB Output is correct
65 Correct 6 ms 5764 KB Output is correct
66 Correct 7 ms 5764 KB Output is correct
67 Correct 11 ms 5764 KB Output is correct
68 Correct 12 ms 5764 KB Output is correct
69 Correct 8 ms 5764 KB Output is correct
70 Correct 10 ms 5764 KB Output is correct
71 Partially correct 89 ms 5764 KB Partially correct - number of queries: 8104
72 Correct 18 ms 5764 KB Output is correct
73 Partially correct 85 ms 5764 KB Partially correct - number of queries: 7999
74 Partially correct 52 ms 5764 KB Partially correct - number of queries: 8044
75 Correct 8 ms 5764 KB Output is correct
76 Partially correct 76 ms 5764 KB Partially correct - number of queries: 7024
77 Partially correct 78 ms 5764 KB Partially correct - number of queries: 7264
78 Correct 18 ms 5764 KB Output is correct
79 Correct 52 ms 5764 KB Output is correct
80 Partially correct 98 ms 5764 KB Partially correct - number of queries: 7326
81 Partially correct 42 ms 5764 KB Partially correct - number of queries: 7196
82 Partially correct 84 ms 5764 KB Partially correct - number of queries: 7258
83 Correct 8 ms 5764 KB Output is correct
84 Partially correct 82 ms 5764 KB Partially correct - number of queries: 6078
85 Partially correct 53 ms 5772 KB Partially correct - number of queries: 7270
86 Correct 11 ms 5772 KB Output is correct
87 Correct 9 ms 5772 KB Output is correct
88 Correct 10 ms 5772 KB Output is correct
89 Correct 9 ms 5772 KB Output is correct
90 Correct 8 ms 5772 KB Output is correct
91 Correct 10 ms 5772 KB Output is correct
92 Correct 8 ms 5772 KB Output is correct
93 Correct 11 ms 5772 KB Output is correct
94 Correct 11 ms 5772 KB Output is correct
95 Correct 11 ms 5772 KB Output is correct
96 Correct 13 ms 5772 KB Output is correct
97 Correct 8 ms 5772 KB Output is correct