# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1048263 |
2024-08-08T06:08:09 Z |
pcc |
The Big Prize (IOI17_prize) |
C++17 |
|
117 ms |
2480 KB |
#include "prize.h"
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#define pii pair<int,int>
#define fs first
#define sc second
#ifdef LOCAL
const int lim = 3;
const int sq = 5;
#else
const int lim = 5000;
const int sq = 480;
#endif
const int mxn = 2e5+10;
pii dp[mxn];
int N;
int big = 1e9;
int ans = 0;
bool done = false;
int C = 0;
ordered_set<int> st;
pii req(int p){
if(dp[p].fs != -1)return dp[p];
C++;
assert(C<=10000);
auto re = ask(p);
return (dp[p] = pii(re[0],re[1]));
}
int check(int p){
auto re = req(p);
if(!re.fs&&!re.sc)return 0;
else if(N-re.fs-re.sc == big)return 2;
else{
st.insert(p);
return 1;
}
}
void dfs(int l,int r){
if(done)return;
cerr<<"DFS: "<<l<<','<<r<<endl;
while(l<=r){
if(!check(l)){
ans = l;
done = true;
return;
}
else if(check(l) == 1){
l++;
}
else break;
}
while(l<=r){
if(!check(r)){
ans = r;
done = true;
return;
}
else if(check(r) == 1){
r--;
}
else break;
}
if(l>=r)return;
int cnt = req(r).fs+req(l).sc-(N-big);
if(!cnt)return;
cerr<<"CHECK: "<<l<<','<<r<<','<<cnt<<endl;
assert(cnt>0);
int mid = (l+r)>>1;
if(check(mid) == 0){
ans = mid;
done = true;
return;
}
if(l == r)return;
dfs(l,mid);
dfs(mid,r);
return;
}
int find_best(int nn) {
N = nn;
int pt = 0;
for(int i = 1;i*i<2e5;i++)pt = i;
cerr<<pt<<endl;
for(auto &i:dp)i = pii(-1,-1);
if(N<=lim){
for(int i = 0;i<N;i++){
auto tmp = req(i);
if(!tmp.fs&&!tmp.sc)return i;
}
assert(false);
return 0;
}
for(int i = 0;i<sq;i++){
auto tmp = req(i);
big = min(big,N-tmp.fs-tmp.sc);
}
cerr<<"BIG: "<<big<<endl;
dfs(0,N-1);
if(!done)exit(0);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1880 KB |
Output is correct |
2 |
Correct |
4 ms |
1976 KB |
Output is correct |
3 |
Correct |
4 ms |
1880 KB |
Output is correct |
4 |
Correct |
2 ms |
1972 KB |
Output is correct |
5 |
Correct |
3 ms |
1976 KB |
Output is correct |
6 |
Correct |
2 ms |
1880 KB |
Output is correct |
7 |
Correct |
3 ms |
1972 KB |
Output is correct |
8 |
Correct |
3 ms |
1880 KB |
Output is correct |
9 |
Correct |
3 ms |
1880 KB |
Output is correct |
10 |
Correct |
3 ms |
1880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1968 KB |
Output is correct |
2 |
Correct |
3 ms |
1980 KB |
Output is correct |
3 |
Correct |
3 ms |
1880 KB |
Output is correct |
4 |
Correct |
3 ms |
1880 KB |
Output is correct |
5 |
Correct |
3 ms |
1880 KB |
Output is correct |
6 |
Correct |
3 ms |
1880 KB |
Output is correct |
7 |
Correct |
3 ms |
1880 KB |
Output is correct |
8 |
Correct |
3 ms |
1880 KB |
Output is correct |
9 |
Correct |
2 ms |
1880 KB |
Output is correct |
10 |
Correct |
3 ms |
1880 KB |
Output is correct |
11 |
Correct |
5 ms |
1880 KB |
Output is correct |
12 |
Correct |
4 ms |
1880 KB |
Output is correct |
13 |
Correct |
10 ms |
2136 KB |
Output is correct |
14 |
Correct |
5 ms |
1880 KB |
Output is correct |
15 |
Correct |
12 ms |
2004 KB |
Output is correct |
16 |
Correct |
68 ms |
2068 KB |
Output is correct |
17 |
Correct |
3 ms |
1880 KB |
Output is correct |
18 |
Partially correct |
87 ms |
2416 KB |
Partially correct - number of queries: 5093 |
19 |
Correct |
2 ms |
1880 KB |
Output is correct |
20 |
Correct |
20 ms |
1880 KB |
Output is correct |
21 |
Correct |
31 ms |
2036 KB |
Output is correct |
22 |
Correct |
8 ms |
1880 KB |
Output is correct |
23 |
Correct |
6 ms |
1880 KB |
Output is correct |
24 |
Correct |
4 ms |
1880 KB |
Output is correct |
25 |
Correct |
40 ms |
2336 KB |
Output is correct |
26 |
Correct |
42 ms |
2384 KB |
Output is correct |
27 |
Correct |
4 ms |
1880 KB |
Output is correct |
28 |
Correct |
73 ms |
2136 KB |
Output is correct |
29 |
Correct |
61 ms |
2336 KB |
Output is correct |
30 |
Partially correct |
90 ms |
2264 KB |
Partially correct - number of queries: 5067 |
31 |
Correct |
2 ms |
1880 KB |
Output is correct |
32 |
Correct |
8 ms |
2008 KB |
Output is correct |
33 |
Correct |
1 ms |
1880 KB |
Output is correct |
34 |
Correct |
37 ms |
2000 KB |
Output is correct |
35 |
Correct |
7 ms |
2136 KB |
Output is correct |
36 |
Correct |
19 ms |
2024 KB |
Output is correct |
37 |
Correct |
5 ms |
1880 KB |
Output is correct |
38 |
Correct |
3 ms |
1880 KB |
Output is correct |
39 |
Correct |
37 ms |
1880 KB |
Output is correct |
40 |
Correct |
93 ms |
2384 KB |
Output is correct |
41 |
Correct |
56 ms |
2172 KB |
Output is correct |
42 |
Correct |
63 ms |
2244 KB |
Output is correct |
43 |
Correct |
52 ms |
1880 KB |
Output is correct |
44 |
Correct |
32 ms |
2060 KB |
Output is correct |
45 |
Correct |
30 ms |
2136 KB |
Output is correct |
46 |
Correct |
4 ms |
1880 KB |
Output is correct |
47 |
Correct |
34 ms |
1880 KB |
Output is correct |
48 |
Correct |
57 ms |
2132 KB |
Output is correct |
49 |
Correct |
8 ms |
1880 KB |
Output is correct |
50 |
Partially correct |
109 ms |
2124 KB |
Partially correct - number of queries: 5102 |
51 |
Correct |
33 ms |
2136 KB |
Output is correct |
52 |
Correct |
3 ms |
1880 KB |
Output is correct |
53 |
Correct |
5 ms |
2004 KB |
Output is correct |
54 |
Correct |
53 ms |
2024 KB |
Output is correct |
55 |
Correct |
5 ms |
1880 KB |
Output is correct |
56 |
Partially correct |
91 ms |
2024 KB |
Partially correct - number of queries: 5074 |
57 |
Correct |
76 ms |
2132 KB |
Output is correct |
58 |
Correct |
71 ms |
2128 KB |
Output is correct |
59 |
Correct |
57 ms |
2052 KB |
Output is correct |
60 |
Correct |
45 ms |
2284 KB |
Output is correct |
61 |
Correct |
6 ms |
2012 KB |
Output is correct |
62 |
Correct |
2 ms |
1880 KB |
Output is correct |
63 |
Correct |
6 ms |
1880 KB |
Output is correct |
64 |
Correct |
4 ms |
1880 KB |
Output is correct |
65 |
Correct |
2 ms |
1972 KB |
Output is correct |
66 |
Correct |
3 ms |
1880 KB |
Output is correct |
67 |
Correct |
5 ms |
1880 KB |
Output is correct |
68 |
Correct |
4 ms |
1880 KB |
Output is correct |
69 |
Correct |
3 ms |
1880 KB |
Output is correct |
70 |
Correct |
4 ms |
1968 KB |
Output is correct |
71 |
Partially correct |
95 ms |
2128 KB |
Partially correct - number of queries: 5239 |
72 |
Correct |
11 ms |
1880 KB |
Output is correct |
73 |
Partially correct |
105 ms |
2192 KB |
Partially correct - number of queries: 5176 |
74 |
Partially correct |
117 ms |
2384 KB |
Partially correct - number of queries: 5203 |
75 |
Correct |
4 ms |
2016 KB |
Output is correct |
76 |
Correct |
90 ms |
2480 KB |
Output is correct |
77 |
Partially correct |
84 ms |
2116 KB |
Partially correct - number of queries: 5196 |
78 |
Correct |
14 ms |
2148 KB |
Output is correct |
79 |
Correct |
44 ms |
2128 KB |
Output is correct |
80 |
Partially correct |
100 ms |
2128 KB |
Partially correct - number of queries: 5184 |
81 |
Partially correct |
88 ms |
2080 KB |
Partially correct - number of queries: 5194 |
82 |
Partially correct |
90 ms |
2384 KB |
Partially correct - number of queries: 5158 |
83 |
Correct |
7 ms |
1880 KB |
Output is correct |
84 |
Correct |
88 ms |
2088 KB |
Output is correct |
85 |
Partially correct |
101 ms |
2124 KB |
Partially correct - number of queries: 5217 |
86 |
Correct |
2 ms |
1880 KB |
Output is correct |
87 |
Correct |
2 ms |
1876 KB |
Output is correct |
88 |
Correct |
2 ms |
1876 KB |
Output is correct |
89 |
Correct |
4 ms |
1880 KB |
Output is correct |
90 |
Correct |
3 ms |
1880 KB |
Output is correct |
91 |
Correct |
4 ms |
2136 KB |
Output is correct |
92 |
Correct |
3 ms |
1880 KB |
Output is correct |
93 |
Correct |
10 ms |
2136 KB |
Output is correct |
94 |
Correct |
9 ms |
1880 KB |
Output is correct |
95 |
Correct |
8 ms |
1880 KB |
Output is correct |
96 |
Correct |
7 ms |
1880 KB |
Output is correct |
97 |
Correct |
3 ms |
1880 KB |
Output is correct |