이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, t;
vector<ll> num;
void dnc(ll l, ll r) {
if (l > r)
return;
if (t == 1) {
ll mn = -1, mx = -1;
if (num.size() < n) MinMax(l, r, &mn, &mx);
if (mn == -1) return;
dnc(mn + 1, mx - 1);
num.push_back(mn);
num.push_back(mx);
return;
}
ll mid = (l + r) >> 1;
ll mn = -1, mx = -1;
MinMax(l, mid, &mn, &mx);
if (mn != -1) {
num.push_back(mn);
num.push_back(mx);
dnc(mn + 1, mx - 1);
dnc(mid + 1, r);
return;
}
if (mid + 1 <= r) {
MinMax(mid, r, &mn, &mx);
if (mn != -1) {
num.push_back(mn);
num.push_back(mx);
dnc(mn + 1, mx - 1);
}
}
}
ll findGap(int T, int N) {
n = N; t = T;
dnc(0, 1e18);
sort(num.begin(), num.end());
ll res = 0;
for (int i = 1; i < num.size(); ++i)
res = max(res, num[i] - num[i - 1]);
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'void dnc(ll, ll)':
gap.cpp:15:24: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
15 | if (num.size() < n) MinMax(l, r, &mn, &mx);
| ~~~~~~~~~~~^~~
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:57:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | for (int i = 1; i < num.size(); ++i)
| ~~^~~~~~~~~~~~
gap.cpp:57:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
57 | for (int i = 1; i < num.size(); ++i)
| ^~~
gap.cpp:60:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
60 | return res;
| ^~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |