# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
101269 |
2019-03-18T06:36:18 Z |
ae04071 |
Gap (APIO16_gap) |
C++11 |
|
82 ms |
1272 KB |
#include "gap.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using namespace std;
using lli=long long;
using pll=pair<lli,lli>;
const lli INF=1000000000000000000ll;
lli sub1(int n) {
lli mx=0, lv=-1, rv=INF+1;
for(int i=0;i<(n+1)/2;i++) {
lli s=lv, t=rv, l, r;
MinMax(s+1, t-1, &l, &r);
if(i!=0) {
mx = max(mx, l-lv);
mx = max(mx, rv-r);
}
lv = l; rv = r;
}
if(!(n&1)) mx = max(mx, rv-lv);
return mx;
}
lli mx=0;
int SEG = 3;
pll dfs(lli lv,lli rv) {
if(lv>rv) return pll(-1,-1);
lli s=lv, t=rv, l,r;
MinMax(s,t,&l,&r);
if(l==-1) return pll(-1, -1);
else if(l==r) return pll(l,l);
else {
lli pr = l, ps, pt;
for(int i=0;i<SEG;i++) {
lli s = pr+1, t=pr+1+(r-l)/SEG;
if(s>=r) break;
if(t>=r) t=r-1;
pll tmp = dfs(s, t);
if(tmp.fi!=-1) {
mx = max(mx, tmp.fi-l);
pr=tmp.se;
}
}
mx = max(mx, r-pr);
return pll(l, r);
}
}
lli sub2(int n) {
dfs(0, INF);
return mx;
}
long long findGap(int T, int N)
{
mx=0;
if(N<=10 || T==1) return sub1(N);
else return sub2(N);
return 0;
}
Compilation message
gap.cpp: In function 'pll dfs(lli, lli)':
gap.cpp:35:21: warning: unused variable 'ps' [-Wunused-variable]
lli pr = l, ps, pt;
^~
gap.cpp:35:25: warning: unused variable 'pt' [-Wunused-variable]
lli pr = l, ps, pt;
^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
17 ms |
512 KB |
Output is correct |
17 |
Correct |
17 ms |
512 KB |
Output is correct |
18 |
Correct |
14 ms |
512 KB |
Output is correct |
19 |
Correct |
16 ms |
512 KB |
Output is correct |
20 |
Correct |
13 ms |
512 KB |
Output is correct |
21 |
Correct |
50 ms |
1016 KB |
Output is correct |
22 |
Correct |
61 ms |
1144 KB |
Output is correct |
23 |
Correct |
70 ms |
1144 KB |
Output is correct |
24 |
Correct |
52 ms |
1144 KB |
Output is correct |
25 |
Correct |
43 ms |
1152 KB |
Output is correct |
26 |
Correct |
54 ms |
1156 KB |
Output is correct |
27 |
Correct |
62 ms |
1144 KB |
Output is correct |
28 |
Correct |
49 ms |
1144 KB |
Output is correct |
29 |
Correct |
50 ms |
1152 KB |
Output is correct |
30 |
Correct |
54 ms |
1144 KB |
Output is correct |
31 |
Correct |
3 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
6 |
Incorrect |
3 ms |
356 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
356 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
11 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
12 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
13 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
14 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
15 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
16 |
Incorrect |
21 ms |
512 KB |
Output isn't correct |
17 |
Incorrect |
16 ms |
512 KB |
Output isn't correct |
18 |
Incorrect |
16 ms |
512 KB |
Output isn't correct |
19 |
Incorrect |
18 ms |
512 KB |
Output isn't correct |
20 |
Incorrect |
7 ms |
512 KB |
Output isn't correct |
21 |
Incorrect |
64 ms |
1172 KB |
Output isn't correct |
22 |
Incorrect |
60 ms |
1144 KB |
Output isn't correct |
23 |
Incorrect |
60 ms |
1152 KB |
Output isn't correct |
24 |
Incorrect |
62 ms |
1152 KB |
Output isn't correct |
25 |
Incorrect |
67 ms |
1152 KB |
Output isn't correct |
26 |
Incorrect |
69 ms |
1144 KB |
Output isn't correct |
27 |
Incorrect |
64 ms |
1144 KB |
Output isn't correct |
28 |
Incorrect |
82 ms |
1272 KB |
Output isn't correct |
29 |
Incorrect |
65 ms |
1064 KB |
Output isn't correct |
30 |
Incorrect |
25 ms |
1152 KB |
Output isn't correct |
31 |
Partially correct |
3 ms |
384 KB |
Partially correct |
32 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |