# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1080566 |
2024-08-29T11:01:21 Z |
TB_ |
The Big Prize (IOI17_prize) |
C++17 |
|
88 ms |
39416 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(i, n) for(ll i = 0; i<(n); i++)
#define F first
#define S second
#define pb push_back
#define deb(x) cout << #x << " = " << (x) << endl
#define deb2(x, y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
typedef vector<ll> vl;
typedef vector<vl> vvl;
int find_best(int n);
std::vector<int> ask(int i);
// std::vector<int> ask(int i){
// ll gaah = 2;
// if(i==gaah) return {0, 0};
// else if(i>gaah) return {1, 0};
// else return {0, 1};
// // if(i==0) return {0, 3};
// // if(i==1) return {0, 0};
// // if(i==2) return {1, 0};
// // if(i==3) return {2, 1};
// // if(i==4) return {2, 1};
// // if(i==5) return {1, 0};
// // else return {3, 0};
// }
ll valval = 1;
struct Node{
Node *lnode, *rnode;
ll l, r, val = valval;
Node(ll l, ll r) : l(l), r(r){
if(r-l>1){
ll mid = (r+l) / 2;
lnode = new Node(l, mid);
rnode = new Node(mid, r);
val = lnode->val+rnode->val;
}
}
void update(ll lo, ll hi){
if(r <= lo || hi <= l) return;
if(r <= hi && lo <= l){
val = 0;
return;
}
lnode->update(lo, hi);rnode->update(lo, hi);
val = lnode->val+rnode->val;
}
void update2(ll lo, ll hi){
if(r <= lo || hi <= l) return;
if(r <= hi && lo <= l){
val = 1;
return;
}
lnode->update2(lo, hi);rnode->update2(lo, hi);
val = lnode->val+rnode->val;
}
ll sumQuery(ll lo, ll hi){
if(r <= lo || hi <= l) return 0;
if(r <= hi && lo <= l) return val;
return lnode->sumQuery(lo, hi)+rnode->sumQuery(lo, hi);
}
ll query(ll x){
if(r-l == 1){
// val = 0;
return l;
}
ll res;
if(lnode->val>x) res = lnode->query(x);
else{
x-=lnode->val;
res = rnode->query(x);
}
val = lnode->val+rnode->val;
return res;
}
};
int find_best(int n){
ll co = 0;
ll prething = -1;
mt19937 rng(42);
fo(i, 500){
ll temp = rng()%n;
co++;
vector<int> res = ask(temp);
// if(res[0] ==0 && res[1] == 0){
// return temp;
// }
prething = max(prething, (ll)res[0]+res[1]);
}
Node st(0, n);
valval = 0;
Node st2(0, n);
map<ll, vector<int>> memo;
while(1){
// deb("gahh");
ll lo = 0;
ll hi = n;
while(1){
ll a = st.sumQuery(0, lo);
ll b = st.sumQuery(0, hi);
ll pos = st.query((a+b)/2);
co++;
vector<int> res;
// deb(pos);
// deb2(lo, hi);
if(memo.count(pos)){
res = memo[pos];
}else{
res = ask(pos);
memo[pos] = res;
}
// deb(pos);
if(res[0] ==0 && res[1] == 0){
return pos;
}
if(res[0]+res[1] <prething){
st.update(pos, pos+1);
st2.update2(pos, pos+1);
break;
}
res[0]-=st2.sumQuery(0, pos);
// deb2(res[0], res[1]);
if(res[0]) hi = pos;
else lo = pos+1;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
37976 KB |
Output is correct |
2 |
Correct |
28 ms |
37968 KB |
Output is correct |
3 |
Correct |
27 ms |
37812 KB |
Output is correct |
4 |
Correct |
29 ms |
37976 KB |
Output is correct |
5 |
Correct |
29 ms |
37932 KB |
Output is correct |
6 |
Correct |
29 ms |
37968 KB |
Output is correct |
7 |
Correct |
27 ms |
37812 KB |
Output is correct |
8 |
Correct |
29 ms |
37976 KB |
Output is correct |
9 |
Correct |
29 ms |
37976 KB |
Output is correct |
10 |
Correct |
32 ms |
37968 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
37780 KB |
Output is correct |
2 |
Correct |
28 ms |
37976 KB |
Output is correct |
3 |
Correct |
31 ms |
37804 KB |
Output is correct |
4 |
Correct |
27 ms |
37976 KB |
Output is correct |
5 |
Correct |
31 ms |
37808 KB |
Output is correct |
6 |
Correct |
28 ms |
37784 KB |
Output is correct |
7 |
Correct |
29 ms |
37976 KB |
Output is correct |
8 |
Correct |
35 ms |
37908 KB |
Output is correct |
9 |
Correct |
29 ms |
37968 KB |
Output is correct |
10 |
Correct |
28 ms |
37860 KB |
Output is correct |
11 |
Correct |
30 ms |
37976 KB |
Output is correct |
12 |
Correct |
31 ms |
37968 KB |
Output is correct |
13 |
Correct |
31 ms |
37968 KB |
Output is correct |
14 |
Correct |
7 ms |
4184 KB |
Output is correct |
15 |
Correct |
35 ms |
37976 KB |
Output is correct |
16 |
Partially correct |
69 ms |
38540 KB |
Partially correct - number of queries: 5050 |
17 |
Correct |
28 ms |
37764 KB |
Output is correct |
18 |
Partially correct |
69 ms |
38560 KB |
Partially correct - number of queries: 5984 |
19 |
Correct |
29 ms |
37976 KB |
Output is correct |
20 |
Correct |
32 ms |
19124 KB |
Output is correct |
21 |
Correct |
45 ms |
38224 KB |
Output is correct |
22 |
Correct |
36 ms |
37816 KB |
Output is correct |
23 |
Correct |
30 ms |
37764 KB |
Output is correct |
24 |
Correct |
30 ms |
37968 KB |
Output is correct |
25 |
Correct |
50 ms |
38224 KB |
Output is correct |
26 |
Correct |
43 ms |
38224 KB |
Output is correct |
27 |
Correct |
27 ms |
37964 KB |
Output is correct |
28 |
Partially correct |
64 ms |
39416 KB |
Partially correct - number of queries: 5520 |
29 |
Correct |
56 ms |
38224 KB |
Output is correct |
30 |
Partially correct |
73 ms |
38576 KB |
Partially correct - number of queries: 5891 |
31 |
Correct |
38 ms |
37968 KB |
Output is correct |
32 |
Correct |
38 ms |
37796 KB |
Output is correct |
33 |
Correct |
3 ms |
344 KB |
Output is correct |
34 |
Correct |
38 ms |
38108 KB |
Output is correct |
35 |
Correct |
30 ms |
38004 KB |
Output is correct |
36 |
Correct |
34 ms |
38056 KB |
Output is correct |
37 |
Correct |
32 ms |
37968 KB |
Output is correct |
38 |
Correct |
32 ms |
37756 KB |
Output is correct |
39 |
Correct |
51 ms |
38220 KB |
Output is correct |
40 |
Partially correct |
68 ms |
38424 KB |
Partially correct - number of queries: 5247 |
41 |
Correct |
53 ms |
38480 KB |
Output is correct |
42 |
Correct |
54 ms |
38828 KB |
Output is correct |
43 |
Correct |
47 ms |
38224 KB |
Output is correct |
44 |
Correct |
47 ms |
38228 KB |
Output is correct |
45 |
Correct |
39 ms |
38184 KB |
Output is correct |
46 |
Correct |
29 ms |
37968 KB |
Output is correct |
47 |
Correct |
48 ms |
38224 KB |
Output is correct |
48 |
Correct |
58 ms |
38348 KB |
Output is correct |
49 |
Correct |
30 ms |
37976 KB |
Output is correct |
50 |
Partially correct |
69 ms |
38824 KB |
Partially correct - number of queries: 5989 |
51 |
Correct |
46 ms |
38380 KB |
Output is correct |
52 |
Correct |
36 ms |
37968 KB |
Output is correct |
53 |
Correct |
28 ms |
37968 KB |
Output is correct |
54 |
Correct |
47 ms |
38344 KB |
Output is correct |
55 |
Correct |
30 ms |
37808 KB |
Output is correct |
56 |
Partially correct |
73 ms |
38516 KB |
Partially correct - number of queries: 5997 |
57 |
Correct |
61 ms |
38224 KB |
Output is correct |
58 |
Correct |
68 ms |
38556 KB |
Output is correct |
59 |
Correct |
58 ms |
38300 KB |
Output is correct |
60 |
Correct |
57 ms |
38156 KB |
Output is correct |
61 |
Correct |
28 ms |
37968 KB |
Output is correct |
62 |
Correct |
35 ms |
37856 KB |
Output is correct |
63 |
Correct |
29 ms |
37968 KB |
Output is correct |
64 |
Correct |
29 ms |
37772 KB |
Output is correct |
65 |
Correct |
31 ms |
38232 KB |
Output is correct |
66 |
Correct |
54 ms |
38416 KB |
Output is correct |
67 |
Correct |
33 ms |
37968 KB |
Output is correct |
68 |
Correct |
29 ms |
38048 KB |
Output is correct |
69 |
Correct |
70 ms |
38224 KB |
Output is correct |
70 |
Correct |
38 ms |
38004 KB |
Output is correct |
71 |
Partially correct |
78 ms |
38480 KB |
Partially correct - number of queries: 6632 |
72 |
Correct |
44 ms |
38040 KB |
Output is correct |
73 |
Partially correct |
74 ms |
38480 KB |
Partially correct - number of queries: 6568 |
74 |
Partially correct |
78 ms |
38528 KB |
Partially correct - number of queries: 6582 |
75 |
Correct |
29 ms |
37976 KB |
Output is correct |
76 |
Partially correct |
88 ms |
38480 KB |
Partially correct - number of queries: 5748 |
77 |
Partially correct |
65 ms |
38480 KB |
Partially correct - number of queries: 6143 |
78 |
Correct |
30 ms |
37968 KB |
Output is correct |
79 |
Correct |
50 ms |
38484 KB |
Output is correct |
80 |
Partially correct |
71 ms |
38560 KB |
Partially correct - number of queries: 6048 |
81 |
Partially correct |
79 ms |
38740 KB |
Partially correct - number of queries: 6072 |
82 |
Partially correct |
61 ms |
38836 KB |
Partially correct - number of queries: 5989 |
83 |
Correct |
31 ms |
37968 KB |
Output is correct |
84 |
Partially correct |
77 ms |
38480 KB |
Partially correct - number of queries: 5104 |
85 |
Partially correct |
64 ms |
38380 KB |
Partially correct - number of queries: 6075 |
86 |
Correct |
39 ms |
38224 KB |
Output is correct |
87 |
Correct |
39 ms |
37968 KB |
Output is correct |
88 |
Correct |
50 ms |
38480 KB |
Output is correct |
89 |
Correct |
40 ms |
38224 KB |
Output is correct |
90 |
Correct |
30 ms |
37888 KB |
Output is correct |
91 |
Correct |
35 ms |
37880 KB |
Output is correct |
92 |
Correct |
40 ms |
38216 KB |
Output is correct |
93 |
Correct |
57 ms |
38216 KB |
Output is correct |
94 |
Partially correct |
82 ms |
38556 KB |
Partially correct - number of queries: 5756 |
95 |
Partially correct |
65 ms |
38652 KB |
Partially correct - number of queries: 5830 |
96 |
Partially correct |
67 ms |
38440 KB |
Partially correct - number of queries: 5729 |
97 |
Partially correct |
64 ms |
38884 KB |
Partially correct - number of queries: 5042 |