제출 #254851

#제출 시각아이디문제언어결과실행 시간메모리
254851maximath_1Gap (APIO16_gap)C++11
컴파일 에러
0 ms0 KiB
/* * APIO 2016 Gap * T = 1 > Two pointers, left right approaching the center * T = 2 > pigeon hole principle > get minimum and maximum, > then divide the array into n - 1 approx. equal parts > By PHP, one of these parts will be empty > Thus, maximum gap >= the length of a part > Now we can simply compare with seg[i].left - seg[i - 1].right */ #include "gap.h" #include <iostream> using namespace std; #define ll long long const ll mn = 0ll, mx = 1e18; ll res = mn, arr[100005]; ll findGap(int t, int n){ if(t == 1){ ll lf = mn, rg = mx, k = 0; for(int i = n; i > 0; i -= 2){ MinMax(lf, rg, &arr[k], &arr[n - 1 - k]); lf = arr[k] + 1; rg = arr[n - 1 - k] - 1; k ++; } for(int i = 1; i < n; i ++) res = max(res, arr[i] - arr[i - 1]); } if(t == 2){ ll lf, rg; MinMax(mn, mx, &lf, &rg); if(n == 2) return rg - lf; ll len = rg - lf - 1ll; ll st = lf + 1, ed = lf; for(int i = 0; i < n - 1; i ++){ ll e = st + len / (n - 1) - 1; if(i < len % (n - 1)) e ++; MinMax(st, e, &lf, &rg); if(lf != -1){ res = max(res, lf - ed); ed = rg; } s = e + 1ll; } } return res; }

컴파일 시 표준 에러 (stderr) 메시지

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:54:4: error: 's' was not declared in this scope
    s = e + 1ll;
    ^