# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
134513 |
2019-07-23T00:41:02 Z |
tri |
The Big Prize (IOI17_prize) |
C++14 |
|
53 ms |
504 KB |
#include <bits/stdc++.h>
#include "prize.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
#define pb push_back
#define f first
#define s second
namespace debug {
const int DEBUG = true;
template<class T1, class T2>
void pr(const pair<T1, T2> &x);
template<class T, size_t SZ>
void pr(const array<T, SZ> &x);
template<class T>
void pr(const vector<T> &x);
template<class T>
void pr(const set<T> &x);
template<class T1, class T2>
void pr(const map<T1, T2> &x);
template<class T>
void pr(const T &x) { if (DEBUG) cout << x; }
template<class T, class... Ts>
void pr(const T &first, const Ts &... rest) { pr(first), pr(rest...); }
template<class T1, class T2>
void pr(const pair<T1, T2> &x) { pr("{", x.f, ", ", x.s, "}"); }
template<class T>
void prIn(const T &x) {
pr("{");
bool fst = 1;
for (auto &a : x) {
pr(fst ? "" : ", ", a), fst = 0;
}
pr("}");
}
template<class T, size_t SZ>
void pr(const array<T, SZ> &x) { prIn(x); }
template<class T>
void pr(const vector<T> &x) { prIn(x); }
template<class T>
void pr(const set<T> &x) { prIn(x); }
template<class T1, class T2>
void pr(const map<T1, T2> &x) { prIn(x); }
void ps() { pr("\n"), cout << flush; }
template<class Arg, class... Args>
void ps(const Arg &first, const Args &... rest) {
pr(first, " ");
ps(rest...);
}
}
using namespace debug;
int callCnt = 0;
int gGrt(int i) {
callCnt++;
// ps("callCnt", callCnt);
vi ret = ask(i);
return ret[0] + ret[1];
}
int maxG, ans = -1;
void srch(int l, int r, int cnt, int lS, int rS) {
if (ans != -1) {
return;
}
if (l > r) {
return;
}
if (cnt == 0) {
return;
}
assert(cnt >= 0);
if(cnt < 0){
exit(0);
}
assert(r - l + 1 >= cnt);
assert(l <= r);
if (r - l + 1 == cnt) {
for (int i = l; i <= r; i++) {
if (gGrt(i) == 0) {
ans = i;
return;
}
}
return;
}
int oMid = (l + r) / 2;
int mid = oMid;
vi ret = ask(mid);
while (ret[0] + ret[1] != maxG) {
if (ret[0] + ret[1] == 0) {
ans = mid;
return;
}
mid++;
if (mid > r) {
int found = mid - oMid;
srch(l, oMid - 1, cnt - found, lS, rS + found);
if(ans != -1){
return;
}
}
ret = ask(mid);
}
int found = mid - oMid;
srch(l, oMid - 1, ret[0] - found - lS, lS, ret[1] + found);
srch(mid + 1, r, ret[1] - rS, ret[0], rS);
}
int find_best(int N) {
if (N < 4000) {
for (int i = 0; i < N; i++) {
if (gGrt(i) == 0) {
return i;
}
}
}
int found = 0;
maxG = 0;
for(int rep = 0; rep < 100; rep++){
int qInd = rand() % N;
maxG = max(maxG, gGrt(qInd));
}
srch(0, N - 1, maxG - found, found, 0);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
312 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
308 KB |
Output is correct |
4 |
Correct |
2 ms |
396 KB |
Output is correct |
5 |
Correct |
3 ms |
248 KB |
Output is correct |
6 |
Correct |
2 ms |
380 KB |
Output is correct |
7 |
Correct |
3 ms |
248 KB |
Output is correct |
8 |
Correct |
3 ms |
248 KB |
Output is correct |
9 |
Correct |
2 ms |
308 KB |
Output is correct |
10 |
Correct |
3 ms |
248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
296 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
424 KB |
Output is correct |
4 |
Correct |
3 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
248 KB |
Output is correct |
6 |
Correct |
3 ms |
308 KB |
Output is correct |
7 |
Correct |
3 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
392 KB |
Output is correct |
9 |
Correct |
3 ms |
248 KB |
Output is correct |
10 |
Correct |
3 ms |
248 KB |
Output is correct |
11 |
Correct |
5 ms |
248 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
8 ms |
248 KB |
Output is correct |
14 |
Correct |
5 ms |
248 KB |
Output is correct |
15 |
Correct |
5 ms |
308 KB |
Output is correct |
16 |
Correct |
28 ms |
424 KB |
Output is correct |
17 |
Correct |
3 ms |
248 KB |
Output is correct |
18 |
Correct |
41 ms |
376 KB |
Output is correct |
19 |
Correct |
3 ms |
248 KB |
Output is correct |
20 |
Correct |
13 ms |
248 KB |
Output is correct |
21 |
Correct |
17 ms |
248 KB |
Output is correct |
22 |
Correct |
5 ms |
248 KB |
Output is correct |
23 |
Correct |
3 ms |
312 KB |
Output is correct |
24 |
Correct |
3 ms |
248 KB |
Output is correct |
25 |
Correct |
22 ms |
248 KB |
Output is correct |
26 |
Correct |
23 ms |
248 KB |
Output is correct |
27 |
Correct |
3 ms |
304 KB |
Output is correct |
28 |
Correct |
41 ms |
304 KB |
Output is correct |
29 |
Correct |
34 ms |
248 KB |
Output is correct |
30 |
Correct |
53 ms |
248 KB |
Output is correct |
31 |
Correct |
3 ms |
416 KB |
Output is correct |
32 |
Correct |
6 ms |
308 KB |
Output is correct |
33 |
Correct |
2 ms |
248 KB |
Output is correct |
34 |
Correct |
15 ms |
248 KB |
Output is correct |
35 |
Correct |
3 ms |
304 KB |
Output is correct |
36 |
Correct |
12 ms |
248 KB |
Output is correct |
37 |
Correct |
4 ms |
248 KB |
Output is correct |
38 |
Correct |
2 ms |
376 KB |
Output is correct |
39 |
Correct |
22 ms |
392 KB |
Output is correct |
40 |
Correct |
22 ms |
388 KB |
Output is correct |
41 |
Correct |
26 ms |
376 KB |
Output is correct |
42 |
Correct |
15 ms |
308 KB |
Output is correct |
43 |
Correct |
18 ms |
248 KB |
Output is correct |
44 |
Correct |
23 ms |
248 KB |
Output is correct |
45 |
Correct |
17 ms |
248 KB |
Output is correct |
46 |
Correct |
3 ms |
396 KB |
Output is correct |
47 |
Correct |
22 ms |
376 KB |
Output is correct |
48 |
Correct |
34 ms |
312 KB |
Output is correct |
49 |
Correct |
7 ms |
388 KB |
Output is correct |
50 |
Correct |
44 ms |
248 KB |
Output is correct |
51 |
Correct |
11 ms |
388 KB |
Output is correct |
52 |
Correct |
3 ms |
376 KB |
Output is correct |
53 |
Correct |
6 ms |
308 KB |
Output is correct |
54 |
Correct |
19 ms |
252 KB |
Output is correct |
55 |
Correct |
2 ms |
392 KB |
Output is correct |
56 |
Correct |
25 ms |
388 KB |
Output is correct |
57 |
Correct |
32 ms |
376 KB |
Output is correct |
58 |
Correct |
32 ms |
252 KB |
Output is correct |
59 |
Correct |
25 ms |
316 KB |
Output is correct |
60 |
Correct |
30 ms |
248 KB |
Output is correct |
61 |
Correct |
3 ms |
376 KB |
Output is correct |
62 |
Correct |
3 ms |
248 KB |
Output is correct |
63 |
Correct |
5 ms |
248 KB |
Output is correct |
64 |
Correct |
3 ms |
400 KB |
Output is correct |
65 |
Correct |
5 ms |
312 KB |
Output is correct |
66 |
Correct |
7 ms |
376 KB |
Output is correct |
67 |
Correct |
7 ms |
248 KB |
Output is correct |
68 |
Correct |
4 ms |
308 KB |
Output is correct |
69 |
Correct |
4 ms |
376 KB |
Output is correct |
70 |
Correct |
6 ms |
248 KB |
Output is correct |
71 |
Correct |
51 ms |
376 KB |
Output is correct |
72 |
Correct |
7 ms |
248 KB |
Output is correct |
73 |
Correct |
50 ms |
248 KB |
Output is correct |
74 |
Correct |
35 ms |
248 KB |
Output is correct |
75 |
Correct |
4 ms |
248 KB |
Output is correct |
76 |
Correct |
23 ms |
396 KB |
Output is correct |
77 |
Correct |
29 ms |
248 KB |
Output is correct |
78 |
Correct |
8 ms |
248 KB |
Output is correct |
79 |
Correct |
19 ms |
376 KB |
Output is correct |
80 |
Correct |
42 ms |
248 KB |
Output is correct |
81 |
Correct |
50 ms |
248 KB |
Output is correct |
82 |
Correct |
35 ms |
248 KB |
Output is correct |
83 |
Correct |
3 ms |
376 KB |
Output is correct |
84 |
Correct |
40 ms |
376 KB |
Output is correct |
85 |
Correct |
25 ms |
376 KB |
Output is correct |
86 |
Correct |
15 ms |
312 KB |
Output is correct |
87 |
Correct |
4 ms |
376 KB |
Output is correct |
88 |
Correct |
18 ms |
376 KB |
Output is correct |
89 |
Correct |
18 ms |
308 KB |
Output is correct |
90 |
Correct |
5 ms |
248 KB |
Output is correct |
91 |
Correct |
15 ms |
248 KB |
Output is correct |
92 |
Correct |
9 ms |
376 KB |
Output is correct |
93 |
Correct |
7 ms |
248 KB |
Output is correct |
94 |
Correct |
8 ms |
248 KB |
Output is correct |
95 |
Correct |
6 ms |
248 KB |
Output is correct |
96 |
Correct |
8 ms |
248 KB |
Output is correct |
97 |
Correct |
3 ms |
248 KB |
Output is correct |