This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "gap.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
long long findGap(int T, int N)
{
ll ans = 0;
if(T == 1){
ll L = -1, R = (ll) 1e18+1;
set<ll> a;
for(int j = 0; j < (N + 1) / 2; j++){
MinMax(L + 1, R - 1, &L, &R);
if(L != -1) a.insert(L); if(R != -1) a.insert(R);
}
for(auto it = a.begin(); it != a.end(); it++){
if(next(it) != a.end()) ans = max(ans, *next(it) - *it);
}
}else{
ll L, R;
MinMax(0, 1e18, &L, &R);
ll tg = 1 + (R - L - 1) / (N - 1);
set<ll> a; a.insert(L); a.insert(R);
for(ll i = L + 1; i < R; i += tg){
ll ll, rr;
MinMax(i, min(R - 1, i + tg - 1), &ll, &rr);
if(ll != -1) a.insert(ll); if(rr != -1) a.insert(rr);
}
for(auto it = a.begin(); it != a.end(); it++){
if(next(it) != a.end()) ans = max(ans, *next(it) - *it);
}
}
return ans;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:13:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
13 | if(L != -1) a.insert(L); if(R != -1) a.insert(R);
| ^~
gap.cpp:13:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
13 | if(L != -1) a.insert(L); if(R != -1) a.insert(R);
| ^~
gap.cpp:26:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
26 | if(ll != -1) a.insert(ll); if(rr != -1) a.insert(rr);
| ^~
gap.cpp:26:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
26 | if(ll != -1) a.insert(ll); if(rr != -1) a.insert(rr);
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |