# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
47279 |
2018-04-30T06:09:15 Z |
Talant |
Gap (APIO16_gap) |
C++17 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
#include "gap.h"
#include "grader.cpp"
using namespace std;
const long long M = (1e6 + 5);
long long ans = 0;
long long a[M];
long long l,r = 1e18;
long long ll,rr;
set<long long> st;
void f (long long mn,long long mx) {
if (mn != -1)
st.insert(mn);
if (mx != -1)
st.insert(mx);
if (mn >= mx)
return;
long long m = (mn + mx) >> 1;
if (mn + 1 <= m) {
long long l = 0,r = 0;
MinMax(mn + 1,m,&l,&r);
f(l,r);
}
if (m + 1 <= mx - 1) {
long long l = 0,r = 0;
MinMax(m + 1,mx - 1,&l,&r);
f(l,r);
}
}
long long findGap(int T, int N)
{
if (T == 1) {
long long o = (N + 1) / 2;
ll = 1,rr = N;
while (o --) {
MinMax(l,r,&a[ll],&a[rr]);
l = a[ll] + 1,r = a[rr] - 1;
ll ++,rr --;
}
for (long long i = 1; i < N; i ++)
ans = max(ans,a[i + 1] - a[i]);
return ans;
}
else {
long long l = 0,r = 0;
MinMax(0,1e18,&l,&r);
f(l,r);
for (auto to : st) {
a[ll] = to;
ll ++;
}
for (long long i = 1; i < N; i ++)
ans = max(ans,a[i + 1] - a[i]);
return ans;
}
}
Compilation message
/tmp/ccdokIRL.o: In function `MinMax(long long, long long, long long*, long long*)':
grader.cpp:(.text+0x0): multiple definition of `MinMax(long long, long long, long long*, long long*)'
/tmp/ccuZgaXz.o:gap.cpp:(.text+0x190): first defined here
/tmp/ccdokIRL.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccuZgaXz.o:gap.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status