답안 #101265

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101265 2019-03-18T06:10:06 Z ae04071 Gap (APIO16_gap) C++11
0 / 100
75 ms 3072 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=INF, lv=-INF, rv=INF+INF;
    for(int i=0;i<(n+1)/2;i++) {
        lli s=lv, t=rv, l, r;
        MinMax(s+1, t-1, &l, &r);
        mx = min(mx, l-lv);
        mx = min(mx, rv-r);
        lv = l; rv = r;
    }
    if(!(n&1)) mx = min(mx, rv-lv);
    return mx;
}
lli mx=INF;
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 = min(mx, lt.fi-l);
        } else if(rt.fi!=-1) {
            mx = min(mx, rt.fi-l);
        } else mx = min(mx, r-l);

        if(rt.se!=-1) mx = min(mx,r-rt.se);
        else if(lt.se!=-1) mx = min(mx, r-lt.se);
        else mx = min(mx, (r-l));
        
        if(lt.se!=-1 && rt.fi!=-1) mx = min(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=INF;

    if(N<=10 || T==1) return sub1(N);
    else return sub2(N);
    
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 Correct 2 ms 384 KB Output is correct
6 Incorrect 2 ms 384 KB Output isn't correct
7 Incorrect 3 ms 512 KB Output isn't correct
8 Incorrect 3 ms 384 KB Output isn't correct
9 Incorrect 0 ms 384 KB Output isn't correct
10 Incorrect 3 ms 384 KB Output isn't correct
11 Incorrect 4 ms 412 KB Output isn't correct
12 Incorrect 4 ms 384 KB Output isn't correct
13 Incorrect 2 ms 384 KB Output isn't correct
14 Incorrect 3 ms 384 KB Output isn't correct
15 Correct 3 ms 384 KB Output is correct
16 Incorrect 14 ms 1152 KB Output isn't correct
17 Incorrect 15 ms 1024 KB Output isn't correct
18 Incorrect 14 ms 1024 KB Output isn't correct
19 Incorrect 14 ms 1024 KB Output isn't correct
20 Incorrect 10 ms 768 KB Output isn't correct
21 Incorrect 48 ms 2936 KB Output isn't correct
22 Incorrect 54 ms 2944 KB Output isn't correct
23 Incorrect 50 ms 2936 KB Output isn't correct
24 Incorrect 52 ms 2980 KB Output isn't correct
25 Correct 39 ms 2304 KB Output is correct
26 Incorrect 52 ms 2936 KB Output isn't correct
27 Incorrect 53 ms 2936 KB Output isn't correct
28 Incorrect 61 ms 3072 KB Output isn't correct
29 Incorrect 51 ms 2940 KB Output isn't correct
30 Incorrect 40 ms 1912 KB Output isn't correct
31 Incorrect 2 ms 384 KB Output isn't correct
32 Incorrect 3 ms 256 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 2 ms 384 KB Output isn't correct
5 Partially correct 2 ms 384 KB Partially correct
6 Incorrect 3 ms 384 KB Output isn't correct
7 Incorrect 2 ms 384 KB Output isn't correct
8 Incorrect 3 ms 384 KB Output isn't correct
9 Incorrect 3 ms 384 KB Output isn't correct
10 Incorrect 3 ms 384 KB Output isn't correct
11 Incorrect 4 ms 384 KB Output isn't correct
12 Incorrect 4 ms 384 KB Output isn't correct
13 Incorrect 3 ms 384 KB Output isn't correct
14 Incorrect 4 ms 384 KB Output isn't correct
15 Partially correct 4 ms 384 KB Partially correct
16 Incorrect 18 ms 1024 KB Output isn't correct
17 Incorrect 23 ms 1148 KB Output isn't correct
18 Incorrect 21 ms 920 KB Output isn't correct
19 Incorrect 20 ms 1024 KB Output isn't correct
20 Incorrect 13 ms 640 KB Output isn't correct
21 Incorrect 75 ms 3064 KB Output isn't correct
22 Incorrect 74 ms 2936 KB Output isn't correct
23 Incorrect 67 ms 2936 KB Output isn't correct
24 Incorrect 66 ms 2912 KB Output isn't correct
25 Partially correct 52 ms 2316 KB Partially correct
26 Incorrect 75 ms 2936 KB Output isn't correct
27 Incorrect 67 ms 3032 KB Output isn't correct
28 Incorrect 67 ms 2936 KB Output isn't correct
29 Incorrect 68 ms 2960 KB Output isn't correct
30 Incorrect 57 ms 1960 KB Output isn't correct
31 Incorrect 3 ms 384 KB Output isn't correct
32 Incorrect 2 ms 384 KB Output isn't correct