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 <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#include "gap.h"
typedef long long ll;
vector<ll> a;
void solve1(ll l, ll r, int n){
ll lf = 1, rf = 1;
MinMax(l, r, &lf, &rf);
cout << lf << ' ' << rf << '\n';
if(lf == -1)return;
a.pb(lf);
if(lf != rf)a.pb(rf);
if(lf == rf || a.size() >= n)return;
l = lf + 1;
r = rf - 1;
if(l > r)return;
ll len = sqrt(r-l)+1;
ll last = l;
while(last <= r){
solve1(last, min(last + len, r), n);
last += len + 1;
}
}
long long findGap(int t, int n)
{
solve1(0, 1e18, n);
sort(all(a));
ll ans = 1;
for(int i = 1; i < a.size(); i++)
ans = max(ans, a[i] - a[i-1]);
return ans;
}
Compilation message (stderr)
gap.cpp: In function 'void solve1(ll, ll, int)':
gap.cpp:20:26: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
20 | if(lf == rf || a.size() >= n)return;
| ~~~~~~~~~^~~~
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for(int i = 1; i < a.size(); i++)
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |