Submission #72449

# Submission time Handle Problem Language Result Execution time Memory
72449 2018-08-26T08:15:14 Z Kmcode The Big Prize (IOI17_prize) C++14
97.67 / 100
74 ms 992 KB
#include<bits/stdc++.h>
using namespace std;

//#include "prize.h"

#include <vector>

int find_best(int n);
std::vector<int> ask(int i);

namespace solver{
	map<int,pair<int,int> > mp;
	int fin;
	pair<int,int> query(int box){
		if(box==-1){
			return make_pair(0,-111);
		}
		if(mp.count(box))return mp[box];
		auto z=ask(box);
		if(z[0]==0&&z[1]==0){
			fin=box;
		}
		return mp[box]=make_pair(z[0],z[1]);
	}
	inline void dfs(int l,int r){
		int ex=query(r-1).first-query(l-1).first;
		int r_cn=query(r-1).first+query(r-1).second;
		int l_cn=query(l-1).first+query(l-1).second;
		if(r_cn==l_cn&&query(l-1).first==query(r-1).first)return;
		if(query(r-1).first==0)return;
		if(l+1==r)return;
		if(fin!=-1)return;
		dfs(l,(l+r)>>1);
		if(fin!=-1)return;
		dfs((l+r)>>1,r);
	}
	int find_best(int n) {
		fin=-1;
		dfs(0,n);
		return fin;
	}
}

int find_best(int n) {
	return solver::find_best(n);
}

Compilation message

prize.cpp: In function 'void solver::dfs(int, int)':
prize.cpp:26:7: warning: unused variable 'ex' [-Wunused-variable]
   int ex=query(r-1).first-query(l-1).first;
       ^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 3 ms 380 KB Output is correct
3 Correct 3 ms 388 KB Output is correct
4 Correct 4 ms 500 KB Output is correct
5 Correct 2 ms 528 KB Output is correct
6 Correct 2 ms 528 KB Output is correct
7 Correct 3 ms 528 KB Output is correct
8 Correct 2 ms 528 KB Output is correct
9 Correct 2 ms 528 KB Output is correct
10 Correct 2 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 528 KB Output is correct
2 Correct 2 ms 528 KB Output is correct
3 Correct 2 ms 556 KB Output is correct
4 Correct 2 ms 556 KB Output is correct
5 Correct 3 ms 556 KB Output is correct
6 Correct 2 ms 556 KB Output is correct
7 Correct 2 ms 556 KB Output is correct
8 Correct 6 ms 556 KB Output is correct
9 Correct 3 ms 560 KB Output is correct
10 Correct 2 ms 560 KB Output is correct
11 Correct 3 ms 572 KB Output is correct
12 Correct 2 ms 572 KB Output is correct
13 Correct 5 ms 576 KB Output is correct
14 Correct 5 ms 576 KB Output is correct
15 Correct 14 ms 576 KB Output is correct
16 Correct 35 ms 820 KB Output is correct
17 Correct 2 ms 820 KB Output is correct
18 Partially correct 61 ms 868 KB Partially correct - number of queries: 5056
19 Correct 3 ms 868 KB Output is correct
20 Correct 9 ms 868 KB Output is correct
21 Correct 21 ms 868 KB Output is correct
22 Correct 4 ms 868 KB Output is correct
23 Correct 2 ms 868 KB Output is correct
24 Correct 2 ms 868 KB Output is correct
25 Correct 19 ms 868 KB Output is correct
26 Correct 20 ms 868 KB Output is correct
27 Correct 6 ms 868 KB Output is correct
28 Correct 44 ms 868 KB Output is correct
29 Correct 25 ms 868 KB Output is correct
30 Correct 54 ms 868 KB Output is correct
31 Correct 2 ms 868 KB Output is correct
32 Correct 5 ms 868 KB Output is correct
33 Correct 2 ms 868 KB Output is correct
34 Correct 30 ms 868 KB Output is correct
35 Correct 4 ms 868 KB Output is correct
36 Correct 16 ms 868 KB Output is correct
37 Correct 3 ms 868 KB Output is correct
38 Correct 2 ms 868 KB Output is correct
39 Correct 27 ms 868 KB Output is correct
40 Correct 62 ms 932 KB Output is correct
41 Correct 18 ms 932 KB Output is correct
42 Correct 33 ms 932 KB Output is correct
43 Correct 21 ms 932 KB Output is correct
44 Correct 15 ms 932 KB Output is correct
45 Correct 21 ms 932 KB Output is correct
46 Correct 2 ms 932 KB Output is correct
47 Correct 26 ms 932 KB Output is correct
48 Correct 42 ms 932 KB Output is correct
49 Correct 6 ms 932 KB Output is correct
50 Partially correct 74 ms 932 KB Partially correct - number of queries: 5007
51 Correct 15 ms 932 KB Output is correct
52 Correct 3 ms 932 KB Output is correct
53 Correct 3 ms 932 KB Output is correct
54 Correct 20 ms 932 KB Output is correct
55 Correct 3 ms 932 KB Output is correct
56 Partially correct 74 ms 932 KB Partially correct - number of queries: 5033
57 Correct 57 ms 932 KB Output is correct
58 Correct 40 ms 932 KB Output is correct
59 Correct 44 ms 932 KB Output is correct
60 Correct 27 ms 932 KB Output is correct
61 Correct 4 ms 932 KB Output is correct
62 Correct 2 ms 932 KB Output is correct
63 Correct 3 ms 932 KB Output is correct
64 Correct 4 ms 932 KB Output is correct
65 Correct 3 ms 932 KB Output is correct
66 Correct 2 ms 932 KB Output is correct
67 Correct 2 ms 932 KB Output is correct
68 Correct 2 ms 932 KB Output is correct
69 Correct 3 ms 932 KB Output is correct
70 Correct 2 ms 932 KB Output is correct
71 Correct 43 ms 932 KB Output is correct
72 Correct 6 ms 932 KB Output is correct
73 Correct 45 ms 932 KB Output is correct
74 Correct 35 ms 932 KB Output is correct
75 Correct 3 ms 932 KB Output is correct
76 Correct 43 ms 932 KB Output is correct
77 Partially correct 47 ms 932 KB Partially correct - number of queries: 5177
78 Correct 6 ms 932 KB Output is correct
79 Correct 26 ms 932 KB Output is correct
80 Partially correct 56 ms 932 KB Partially correct - number of queries: 5233
81 Partially correct 61 ms 992 KB Partially correct - number of queries: 5216
82 Partially correct 51 ms 992 KB Partially correct - number of queries: 5125
83 Correct 3 ms 992 KB Output is correct
84 Correct 39 ms 992 KB Output is correct
85 Partially correct 46 ms 992 KB Partially correct - number of queries: 5180
86 Correct 7 ms 992 KB Output is correct
87 Correct 3 ms 992 KB Output is correct
88 Correct 9 ms 992 KB Output is correct
89 Correct 9 ms 992 KB Output is correct
90 Correct 4 ms 992 KB Output is correct
91 Correct 9 ms 992 KB Output is correct
92 Correct 2 ms 992 KB Output is correct
93 Correct 5 ms 992 KB Output is correct
94 Correct 4 ms 992 KB Output is correct
95 Correct 5 ms 992 KB Output is correct
96 Correct 4 ms 992 KB Output is correct
97 Correct 2 ms 992 KB Output is correct