| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1101316 | huyngo | Gap (APIO16_gap) | C++17 | 43 ms | 4100 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
long long findGap(int T, int N) {
if (T == 1) {
vector<ll> a;
auto calc = [&](auto self, ll l, ll r) -> void {
if (l > r || a.size() == N) return;
ll x, y;
MinMax(l, r, &x, &y);
if (x != -1)
a.push_back(x);
if (y != x)
a.push_back(y);
self(self, x + 1, y - 1);
};
calc(calc, 0, 1e18);
sort(a.begin(), a.end());
ll res = a[1] - a[0];
for (int i = 2; i < N; ++i)
res = max(res, a[i] - a[i - 1]);
return res;
}
ll x, y, res = 1;
MinMax(0, 1e18, &x, &y);
while (true) {
// find furest from x where [x+1, m] = -1
if (x >= y || x + res >= y) break;
ll u, v;
MinMax(x + 1, x + res, &u, &v);
if (u != -1) {
x = v;
continue;
}
ll l = x + res, r = y, sf = l;
while (l <= r) {
ll m = (l + r) / 2;
MinMax(x + 1, m, &u, &v);
if (u == -1) {
l = m + 1;
sf = max(sf, m);
res = max(res, m - x + 1);
}
else
r = m - 1;
}
x = sf + 1;
}
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
