Submission #101273

# Submission time Handle Problem Language Result Execution time Memory
101273 2019-03-18T06:51:10 Z ae04071 Gap (APIO16_gap) C++11
46.5773 / 100
99 ms 1276 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, ints=l;
        for(int i=0;i<SEG;i++) {
            lli s = ints+1, t=ints+1+(r-l)/SEG+1;
            //printf("%lld %lld, %lld %lld\n",l,r,s,t);
            if(s>=r) break;
            if(t>=r) t=r-1;
            
            pll tmp = dfs(s, t);
            if(tmp.fi!=-1) {
                //printf("#%lld %lld\n",l, tmp.fi);
                //printf("#%lld %lld\n",tmp.fi,tmp.se);
                mx = max(mx, tmp.fi-pr);
                pr=tmp.se;
                //printf("@%lld\n",pr);
            }
            ints = t;
        }
        //printf("@%lld %lld\n",pr,r);
        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;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 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 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 356 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 404 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 15 ms 512 KB Output is correct
17 Correct 18 ms 484 KB Output is correct
18 Correct 15 ms 512 KB Output is correct
19 Correct 19 ms 512 KB Output is correct
20 Correct 11 ms 512 KB Output is correct
21 Correct 67 ms 1144 KB Output is correct
22 Correct 52 ms 1152 KB Output is correct
23 Correct 53 ms 1144 KB Output is correct
24 Correct 69 ms 1144 KB Output is correct
25 Correct 46 ms 1144 KB Output is correct
26 Correct 55 ms 1144 KB Output is correct
27 Correct 66 ms 1144 KB Output is correct
28 Correct 67 ms 1144 KB Output is correct
29 Correct 51 ms 1168 KB Output is correct
30 Correct 47 ms 1152 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Partially correct 2 ms 384 KB Partially correct
3 Partially correct 2 ms 384 KB Partially correct
4 Partially correct 2 ms 384 KB Partially correct
5 Partially correct 2 ms 384 KB Partially correct
6 Partially correct 2 ms 384 KB Partially correct
7 Partially correct 2 ms 384 KB Partially correct
8 Partially correct 3 ms 384 KB Partially correct
9 Partially correct 3 ms 384 KB Partially correct
10 Partially correct 2 ms 384 KB Partially correct
11 Partially correct 3 ms 384 KB Partially correct
12 Partially correct 3 ms 384 KB Partially correct
13 Partially correct 3 ms 384 KB Partially correct
14 Partially correct 3 ms 384 KB Partially correct
15 Partially correct 3 ms 384 KB Partially correct
16 Partially correct 20 ms 512 KB Partially correct
17 Partially correct 22 ms 512 KB Partially correct
18 Partially correct 23 ms 640 KB Partially correct
19 Partially correct 22 ms 512 KB Partially correct
20 Partially correct 13 ms 512 KB Partially correct
21 Partially correct 91 ms 1144 KB Partially correct
22 Partially correct 77 ms 1104 KB Partially correct
23 Partially correct 96 ms 1144 KB Partially correct
24 Partially correct 99 ms 1152 KB Partially correct
25 Partially correct 84 ms 1156 KB Partially correct
26 Partially correct 81 ms 1196 KB Partially correct
27 Partially correct 87 ms 1116 KB Partially correct
28 Partially correct 75 ms 1272 KB Partially correct
29 Partially correct 80 ms 1144 KB Partially correct
30 Partially correct 53 ms 1276 KB Partially correct
31 Partially correct 2 ms 384 KB Partially correct
32 Partially correct 3 ms 356 KB Partially correct