이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
// #include "grader.cpp"
#include "gap.h"
using namespace std;
typedef long long ll;
set<ll> st;
void recur(ll l, ll r){
if (r < l) return ;
if (r - l <= 1){
MinMax(l, r, &l, &r);
if (l != -1){
st.insert(l);
st.insert(r);
}
return ;
}
ll mid = (l + r) / 2;
ll mn, mx;
MinMax(l, mid, &mn, &mx);
if (mn != -1){
st.insert(mn);
st.insert(mx);
recur(mn + 1, mx - 1);
}
MinMax(mid + 1, r, &mn, &mx);
if (mn != -1){
st.insert(mn);
st.insert(mx);
recur(mn + 1, mx - 1);
}
}
ll findGap(int T, int N){
if (T == 1){
ll mn = 0, mx = 1e18;
while (N > 0){
N -= 2;
MinMax(mn, mx, &mn, &mx);
st.insert(mn);
st.insert(mx);
mn++;
mx--;
}
}
else{
recur(0, 1e18);
}
vector<ll> vec;
for (ll x : st)
vec.push_back(x);
ll res = 0;
for (ll i = 1; i < vec.size(); i ++)
res = max(res, vec[i] - vec[i - 1]);
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:63:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | for (ll i = 1; i < vec.size(); i ++)
| ~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |