이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;
const ll MAX = 1000000000000000000ll;
ll findGap(int T, int N)
{
if(T == 1){
ll l = 0, r = MAX;
vector<ll> v;
while(l <= r && v.size() < N){
ll mn, mx;
MinMax(l, r, &mn, &mx);
v.push_back(mn);
v.push_back(mx);
l = mn + 1;
r = mx - 1;
}
sort(v.begin(), v.end());
ll ans = 1;
for (int i = 1; i < v.size(); i++)
{
ans = max(ans, v[i] - v[i - 1]);
}
return ans;
}
ll mn, mx;
MinMax(0, MAX, &mn, &mx);
ll ans = 1;
ll p = mn;
while(p != mx){
ll l = 0, h = 0;
ll dist = ans;
while(true){
MinMax(p + 1, p + dist, &l, &h);
if(l == -1){
dist *= 2;
continue;
}
ans = max(ans, l - p);
p = h;
break;
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:16:34: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
16 | while(l <= r && v.size() < N){
| ~~~~~~~~~^~~
gap.cpp:26:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for (int i = 1; i < v.size(); i++)
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |