Submission #137566

# Submission time Handle Problem Language Result Execution time Memory
137566 2019-07-28T06:36:48 Z Mahdi_Jfri The Big Prize (IOI17_prize) C++14
90 / 100
108 ms 5440 KB
#include "prize.h"
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back

const int maxn = 2e5 + 20;

vector<int> res[maxn] , candid;

int mx;

vector<int> reval(int k)
{
	if(!res[k].empty())
		return res[k];

	res[k] = ask(k);
	while(k >= 1000 && res[k][0] + res[k][1] > mx) cout << 1/0;
	return res[k];
}

void solve(int l , int r)
{
	while(l < r)
	{
		auto tmp = reval(l);
		if(tmp[0] + tmp[1] != mx)
			candid.pb(l++);
		else
			break;
	}
	while(l < r)
	{
		r--;
		auto tmp = reval(r);
		if(tmp[0] + tmp[1] != mx)
			candid.pb(r);
		else
			break;
	}

	if(l >= r)
		return;

	reval(l); reval(r);
	if(res[r][0] - res[l][0] == 0)
		return;

	int m = (l + r) / 2;
	solve(m , r + 1);
	solve(l , m);
}

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

	for(int i = 0; i < 600; i++)
	{
		vector<int> tmp = reval(i);
		mx = max(mx , tmp[0] + tmp[1]);
	}

	solve(0 , n);

	for(auto x : candid)
	{
		auto tmp = reval(x);
		if(tmp[0] + tmp[1] == 0)
			return x;
	}
	cout << 1/0;
	return -85;
}





Compilation message

prize.cpp: In function 'std::vector<int> reval(int)':
prize.cpp:21:58: warning: division by zero [-Wdiv-by-zero]
  while(k >= 1000 && res[k][0] + res[k][1] > mx) cout << 1/0;
                                                         ~^~
prize.cpp: In function 'int find_best(int)':
prize.cpp:82:11: warning: division by zero [-Wdiv-by-zero]
  cout << 1/0;
          ~^~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 5136 KB Output is correct
2 Correct 10 ms 5136 KB Output is correct
3 Correct 9 ms 5136 KB Output is correct
4 Correct 14 ms 4984 KB Output is correct
5 Correct 12 ms 4984 KB Output is correct
6 Correct 13 ms 4984 KB Output is correct
7 Correct 10 ms 5124 KB Output is correct
8 Correct 13 ms 5032 KB Output is correct
9 Correct 9 ms 5136 KB Output is correct
10 Correct 12 ms 5112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 5128 KB Output is correct
2 Correct 13 ms 4984 KB Output is correct
3 Correct 9 ms 5136 KB Output is correct
4 Correct 12 ms 4984 KB Output is correct
5 Correct 10 ms 5080 KB Output is correct
6 Correct 9 ms 5124 KB Output is correct
7 Correct 13 ms 5120 KB Output is correct
8 Correct 10 ms 5028 KB Output is correct
9 Correct 9 ms 5136 KB Output is correct
10 Correct 10 ms 5032 KB Output is correct
11 Correct 14 ms 5156 KB Output is correct
12 Correct 14 ms 5156 KB Output is correct
13 Correct 20 ms 4984 KB Output is correct
14 Correct 30 ms 5060 KB Output is correct
15 Partially correct 88 ms 5356 KB Partially correct - number of queries: 7763
16 Partially correct 96 ms 5228 KB Partially correct - number of queries: 8142
17 Partially correct 90 ms 5388 KB Partially correct - number of queries: 8216
18 Partially correct 81 ms 5380 KB Partially correct - number of queries: 8117
19 Partially correct 93 ms 5232 KB Partially correct - number of queries: 7831
20 Partially correct 36 ms 5284 KB Partially correct - number of queries: 5474
21 Partially correct 83 ms 5236 KB Partially correct - number of queries: 8067
22 Partially correct 57 ms 5216 KB Partially correct - number of queries: 6389
23 Correct 11 ms 5116 KB Output is correct
24 Correct 20 ms 5092 KB Output is correct
25 Partially correct 80 ms 5240 KB Partially correct - number of queries: 7391
26 Partially correct 87 ms 5240 KB Partially correct - number of queries: 7443
27 Correct 11 ms 5032 KB Output is correct
28 Partially correct 78 ms 5216 KB Partially correct - number of queries: 7187
29 Partially correct 42 ms 5236 KB Partially correct - number of queries: 6324
30 Partially correct 82 ms 5376 KB Partially correct - number of queries: 8045
31 Partially correct 92 ms 5160 KB Partially correct - number of queries: 8115
32 Correct 14 ms 5156 KB Output is correct
33 Correct 6 ms 4984 KB Output is correct
34 Partially correct 61 ms 5260 KB Partially correct - number of queries: 8126
35 Correct 18 ms 5032 KB Output is correct
36 Partially correct 76 ms 5284 KB Partially correct - number of queries: 8099
37 Correct 14 ms 5156 KB Output is correct
38 Correct 11 ms 5136 KB Output is correct
39 Partially correct 73 ms 5216 KB Partially correct - number of queries: 8083
40 Partially correct 72 ms 5228 KB Partially correct - number of queries: 7107
41 Partially correct 87 ms 5372 KB Partially correct - number of queries: 8119
42 Partially correct 82 ms 5288 KB Partially correct - number of queries: 8119
43 Partially correct 84 ms 5256 KB Partially correct - number of queries: 7953
44 Partially correct 89 ms 5368 KB Partially correct - number of queries: 8169
45 Partially correct 77 ms 5164 KB Partially correct - number of queries: 7317
46 Partially correct 51 ms 5252 KB Partially correct - number of queries: 8245
47 Partially correct 78 ms 5292 KB Partially correct - number of queries: 7477
48 Partially correct 89 ms 5216 KB Partially correct - number of queries: 8126
49 Partially correct 84 ms 5240 KB Partially correct - number of queries: 8151
50 Partially correct 90 ms 5244 KB Partially correct - number of queries: 8156
51 Partially correct 71 ms 5256 KB Partially correct - number of queries: 8156
52 Partially correct 76 ms 5212 KB Partially correct - number of queries: 8145
53 Correct 11 ms 5136 KB Output is correct
54 Partially correct 91 ms 5316 KB Partially correct - number of queries: 8050
55 Partially correct 57 ms 5316 KB Partially correct - number of queries: 8140
56 Partially correct 92 ms 5324 KB Partially correct - number of queries: 8177
57 Partially correct 80 ms 5212 KB Partially correct - number of queries: 8180
58 Partially correct 84 ms 5244 KB Partially correct - number of queries: 8263
59 Partially correct 91 ms 5196 KB Partially correct - number of queries: 8161
60 Partially correct 70 ms 5340 KB Partially correct - number of queries: 8055
61 Correct 11 ms 5040 KB Output is correct
62 Correct 16 ms 4984 KB Output is correct
63 Correct 11 ms 5036 KB Output is correct
64 Correct 14 ms 4984 KB Output is correct
65 Correct 10 ms 5028 KB Output is correct
66 Correct 16 ms 5008 KB Output is correct
67 Correct 12 ms 5032 KB Output is correct
68 Correct 12 ms 4984 KB Output is correct
69 Correct 16 ms 5032 KB Output is correct
70 Correct 17 ms 5024 KB Output is correct
71 Partially correct 108 ms 5224 KB Partially correct - number of queries: 9645
72 Correct 25 ms 4984 KB Output is correct
73 Partially correct 107 ms 5236 KB Partially correct - number of queries: 9526
74 Partially correct 59 ms 5440 KB Partially correct - number of queries: 9577
75 Correct 16 ms 5020 KB Output is correct
76 Partially correct 66 ms 5272 KB Partially correct - number of queries: 8421
77 Partially correct 103 ms 5252 KB Partially correct - number of queries: 9082
78 Correct 17 ms 5052 KB Output is correct
79 Correct 55 ms 5172 KB Output is correct
80 Partially correct 93 ms 5292 KB Partially correct - number of queries: 9055
81 Partially correct 99 ms 5284 KB Partially correct - number of queries: 9073
82 Partially correct 94 ms 5236 KB Partially correct - number of queries: 8955
83 Correct 15 ms 5112 KB Output is correct
84 Partially correct 81 ms 5128 KB Partially correct - number of queries: 7611
85 Partially correct 91 ms 5240 KB Partially correct - number of queries: 9014
86 Correct 13 ms 5032 KB Output is correct
87 Correct 13 ms 4984 KB Output is correct
88 Correct 13 ms 5112 KB Output is correct
89 Correct 14 ms 4984 KB Output is correct
90 Correct 13 ms 5032 KB Output is correct
91 Correct 13 ms 4984 KB Output is correct
92 Correct 10 ms 5120 KB Output is correct
93 Correct 18 ms 5016 KB Output is correct
94 Correct 13 ms 5048 KB Output is correct
95 Correct 22 ms 4984 KB Output is correct
96 Correct 18 ms 4984 KB Output is correct
97 Correct 15 ms 4984 KB Output is correct