이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MX = 1e18;
ll x, y;
vector<ll> p;
void query(ll l, ll r) {
MinMax(l,r,&x,&y);
if (x != -1) p.push_back(x);
if (y != -1) p.push_back(y);
}
ll findGap(int T, int N) {
ll l = 0, r = MX;
if (T == 1) {
for (int i = 1; i <= (N+1)/2 && l <= r; i++) {
query(l,r);
l = x+1, r = y-1;
}
}
else {
query(l,r);
l = x+1, r = y-1;
for (int i = N-1; i > 0; i--) {
ll q = l+(r-l)/i;
query(l,q);
l = q+1;
}
}
sort(p.begin(),p.end());
p.resize(unique(p.begin(),p.end())-p.begin());
ll ans = 0;
for (int i = 1; i < p.size(); i++) {
ans = max(ans,p[i]-p[i-1]);
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:38:20: 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 < p.size(); i++) {
| ~~^~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |