Submission #101266

# Submission time Handle Problem Language Result Execution time Memory
101266 2019-03-18T06:16:34 Z ae04071 Gap (APIO16_gap) C++11
0 / 100
78 ms 1224 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=-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 = 2;
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 {
        pll lt = dfs(l+1, (l+r)/2);
        pll rt = dfs((l+r)/2+1, r-1);
        
        if(lt.fi!=-1) {
            mx = max(mx, lt.fi-l);
        } else if(rt.fi!=-1) {
            mx = max(mx, rt.fi-l);
        } else mx = max(mx, r-l);

        if(rt.se!=-1) mx = max(mx,r-rt.se);
        else if(lt.se!=-1) mx = max(mx, r-lt.se);
        else mx = max(mx, (r-l));
        
        if(lt.se!=-1 && rt.fi!=-1) mx = max(mx, rt.fi-lt.se);
        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 Runtime error 2 ms 256 KB Execution failed because the return code was nonzero
2 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
3 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
4 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
5 Runtime error 3 ms 384 KB Execution failed because the return code was nonzero
6 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
7 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
8 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
9 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
10 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
11 Runtime error 3 ms 384 KB Execution failed because the return code was nonzero
12 Runtime error 3 ms 384 KB Execution failed because the return code was nonzero
13 Runtime error 3 ms 384 KB Execution failed because the return code was nonzero
14 Runtime error 3 ms 384 KB Execution failed because the return code was nonzero
15 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
16 Runtime error 9 ms 512 KB Execution failed because the return code was nonzero
17 Runtime error 11 ms 640 KB Execution failed because the return code was nonzero
18 Runtime error 8 ms 512 KB Execution failed because the return code was nonzero
19 Runtime error 9 ms 512 KB Execution failed because the return code was nonzero
20 Runtime error 5 ms 512 KB Execution failed because the return code was nonzero
21 Runtime error 26 ms 1116 KB Execution failed because the return code was nonzero
22 Runtime error 30 ms 1152 KB Execution failed because the return code was nonzero
23 Runtime error 26 ms 1144 KB Execution failed because the return code was nonzero
24 Runtime error 26 ms 1144 KB Execution failed because the return code was nonzero
25 Runtime error 31 ms 1116 KB Execution failed because the return code was nonzero
26 Runtime error 29 ms 1144 KB Execution failed because the return code was nonzero
27 Runtime error 30 ms 1144 KB Execution failed because the return code was nonzero
28 Runtime error 28 ms 1152 KB Execution failed because the return code was nonzero
29 Runtime error 29 ms 1144 KB Execution failed because the return code was nonzero
30 Runtime error 15 ms 1152 KB Execution failed because the return code was nonzero
31 Runtime error 3 ms 384 KB Execution failed because the return code was nonzero
32 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 384 KB Execution failed because the return code was nonzero
2 Partially correct 3 ms 384 KB Partially correct
3 Partially correct 2 ms 384 KB Partially correct
4 Partially correct 4 ms 384 KB Partially correct
5 Partially correct 3 ms 384 KB Partially correct
6 Partially correct 3 ms 384 KB Partially correct
7 Partially correct 2 ms 384 KB Partially correct
8 Partially correct 2 ms 384 KB Partially correct
9 Partially correct 2 ms 384 KB Partially correct
10 Partially correct 2 ms 384 KB Partially correct
11 Partially correct 5 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 18 ms 512 KB Partially correct
17 Partially correct 21 ms 512 KB Partially correct
18 Partially correct 22 ms 512 KB Partially correct
19 Partially correct 18 ms 640 KB Partially correct
20 Partially correct 14 ms 512 KB Partially correct
21 Partially correct 66 ms 1152 KB Partially correct
22 Partially correct 65 ms 1192 KB Partially correct
23 Partially correct 68 ms 1144 KB Partially correct
24 Partially correct 65 ms 1144 KB Partially correct
25 Partially correct 64 ms 1152 KB Partially correct
26 Partially correct 78 ms 1144 KB Partially correct
27 Partially correct 75 ms 1224 KB Partially correct
28 Partially correct 72 ms 1144 KB Partially correct
29 Partially correct 67 ms 1144 KB Partially correct
30 Partially correct 53 ms 1180 KB Partially correct
31 Partially correct 2 ms 384 KB Partially correct
32 Partially correct 3 ms 384 KB Partially correct