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>
#include "gap.h"
using namespace std;
typedef long long int64;
int64 findGap(int t, int n){
vector <int64> v;
int64 rs = -1;
if (t == 1) {
int64 l = 0, r = 1e18, mn = -1, mx = -1;
set <int64> s;
vector <int64> p1, p2;
while (l <= r) {
MinMax(l, r, &mn, &mx);
if (mn == -1) break;
s.insert(mn);
s.insert(mx);
l = mn + 1, r = mx - 1;
if (mn == mx) break;
}
for (int64 i: s) v.push_back(i);
}
else {
set <int64> s;
int64 last = -1, mn = -1, mx = -1;
for (int i = 0; i < n; i++){
int64 l = last + 1;
// cout << "> " << l << "\n";
auto it = s.lower_bound(l);
int64 r = (it == s.end() ? 1e18: *it);
while (l <= r) {
int64 mid = (l + r) / 2;
MinMax(l, mid, &mn, &mx);
// cout << l << " " << r << " " << mn << " " << mx << "\n";
if (mn == -1) break;
s.insert(mn);
s.insert(mx);
if (mn == mx) break;
r = min(mid - 1, mx - 1);
// l = mn + 1;
}
last = *s.lower_bound(last + 1);
}
for (int64 i: s) v.push_back(i);
}
assert(v.size() == n);
for (int i = 1; i < n; i++){
rs = max(rs, v[i] - v[i-1]);
}
return rs;
}
Compilation message (stderr)
In file included from /usr/include/c++/10/cassert:44,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
from gap.cpp:1:
gap.cpp: In function 'int64 findGap(int, int)':
gap.cpp:46:18: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
46 | assert(v.size() == n);
| ~~~~~~~~~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |