Submission #70058

# Submission time Handle Problem Language Result Execution time Memory
70058 2018-08-22T09:59:48 Z E869120 The Big Prize (IOI17_prize) C++14
20 / 100
109 ms 1728 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;

vector<int>vec;int N;

pair<int,int> asks(int p){
	vector<int>Z = ask(p);
	return make_pair(Z[0],Z[1]);
}

int find_best(int n) {
	srand((unsigned)time(NULL));
	N=n;
	vector<int>vec;for(int i=0;i<n;i++) vec.push_back(i);
	
	while(vec.size()>=2){
		int minx=0;
		for(int i=0;i<5;i++){
			pair<int,int>A=asks(vec[rand()%vec.size()]);
			minx=max(minx,A.first+A.second);
		}
		
		int s = 0;for(int i=0;i<20;i++){if((1<<i)<=vec.size()) s=i+1;}
		int cnt=0,ret=0;vector<int>vec2;
		while(true){
			int c = 0;
			for(int i=s-1;i>=0;i--){
				int pos = vec[min(c + (1<<i), (int)vec.size() - 1)];
				if(pos <= ret) c += (1<<i);
				else{
					pair<int,int>Z = asks(pos);
					if(Z.first+Z.second==minx && Z.first<=cnt) c+=(1<<i);
				}
			}
			if(c==(1<<s)-1){
				break;
			}
			else{
				// results = vec[c + 1]
				if(c == 0){
					int pos = vec[0];
					pair<int, int> Z = asks(pos);
					if(Z.first + Z.second != minx) c = -1;
				}
				vec2.push_back(vec[c + 1]);
				ret = vec[c + 1];
			}
			cnt++;
		}
		vec=vec2;
	}
	return vec[0];
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:24:44: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   int s = 0;for(int i=0;i<20;i++){if((1<<i)<=vec.size()) s=i+1;}
                                      ~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1516 KB Output is correct
2 Correct 5 ms 1516 KB Output is correct
3 Correct 5 ms 1516 KB Output is correct
4 Correct 5 ms 1560 KB Output is correct
5 Correct 4 ms 1728 KB Output is correct
6 Correct 4 ms 1728 KB Output is correct
7 Correct 5 ms 1728 KB Output is correct
8 Correct 5 ms 1728 KB Output is correct
9 Correct 6 ms 1728 KB Output is correct
10 Correct 4 ms 1728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1728 KB Output is correct
2 Correct 5 ms 1728 KB Output is correct
3 Correct 5 ms 1728 KB Output is correct
4 Correct 5 ms 1728 KB Output is correct
5 Correct 6 ms 1728 KB Output is correct
6 Correct 7 ms 1728 KB Output is correct
7 Correct 3 ms 1728 KB Output is correct
8 Correct 5 ms 1728 KB Output is correct
9 Correct 5 ms 1728 KB Output is correct
10 Correct 5 ms 1728 KB Output is correct
11 Correct 11 ms 1728 KB Output is correct
12 Correct 15 ms 1728 KB Output is correct
13 Correct 12 ms 1728 KB Output is correct
14 Correct 24 ms 1728 KB Output is correct
15 Partially correct 77 ms 1728 KB Partially correct - number of queries: 6623
16 Partially correct 65 ms 1728 KB Partially correct - number of queries: 7175
17 Partially correct 93 ms 1728 KB Partially correct - number of queries: 7184
18 Partially correct 89 ms 1728 KB Partially correct - number of queries: 7172
19 Partially correct 78 ms 1728 KB Partially correct - number of queries: 6732
20 Correct 55 ms 1728 KB Output is correct
21 Partially correct 62 ms 1728 KB Partially correct - number of queries: 7074
22 Partially correct 41 ms 1728 KB Partially correct - number of queries: 5285
23 Correct 6 ms 1728 KB Output is correct
24 Correct 13 ms 1728 KB Output is correct
25 Partially correct 92 ms 1728 KB Partially correct - number of queries: 6971
26 Partially correct 78 ms 1728 KB Partially correct - number of queries: 6964
27 Correct 6 ms 1728 KB Output is correct
28 Partially correct 67 ms 1728 KB Partially correct - number of queries: 6838
29 Partially correct 47 ms 1728 KB Partially correct - number of queries: 5720
30 Partially correct 109 ms 1728 KB Partially correct - number of queries: 7072
31 Partially correct 32 ms 1728 KB Partially correct - number of queries: 7091
32 Correct 18 ms 1728 KB Output is correct
33 Correct 4 ms 1728 KB Output is correct
34 Partially correct 77 ms 1728 KB Partially correct - number of queries: 7191
35 Correct 9 ms 1728 KB Output is correct
36 Partially correct 66 ms 1728 KB Partially correct - number of queries: 7117
37 Correct 11 ms 1728 KB Output is correct
38 Correct 8 ms 1728 KB Output is correct
39 Partially correct 84 ms 1728 KB Partially correct - number of queries: 7088
40 Partially correct 89 ms 1728 KB Partially correct - number of queries: 6049
41 Partially correct 75 ms 1728 KB Partially correct - number of queries: 7201
42 Partially correct 38 ms 1728 KB Partially correct - number of queries: 7201
43 Partially correct 30 ms 1728 KB Partially correct - number of queries: 6978
44 Partially correct 103 ms 1728 KB Partially correct - number of queries: 7196
45 Partially correct 72 ms 1728 KB Partially correct - number of queries: 6973
46 Partially correct 104 ms 1728 KB Partially correct - number of queries: 7182
47 Partially correct 62 ms 1728 KB Partially correct - number of queries: 7009
48 Partially correct 76 ms 1728 KB Partially correct - number of queries: 7185
49 Partially correct 35 ms 1728 KB Partially correct - number of queries: 7187
50 Partially correct 81 ms 1728 KB Partially correct - number of queries: 7172
51 Partially correct 65 ms 1728 KB Partially correct - number of queries: 7198
52 Partially correct 73 ms 1728 KB Partially correct - number of queries: 7181
53 Correct 8 ms 1728 KB Output is correct
54 Partially correct 100 ms 1728 KB Partially correct - number of queries: 7077
55 Partially correct 31 ms 1728 KB Partially correct - number of queries: 7180
56 Partially correct 77 ms 1728 KB Partially correct - number of queries: 7173
57 Partially correct 78 ms 1728 KB Partially correct - number of queries: 7092
58 Partially correct 47 ms 1728 KB Partially correct - number of queries: 7182
59 Partially correct 52 ms 1728 KB Partially correct - number of queries: 7201
60 Partially correct 70 ms 1728 KB Partially correct - number of queries: 7079
61 Correct 7 ms 1728 KB Output is correct
62 Incorrect 9 ms 1728 KB answer is not correct
63 Halted 0 ms 0 KB -