Submission #956106

# Submission time Handle Problem Language Result Execution time Memory
956106 2024-04-01T05:25:25 Z thinknoexit Gap (APIO16_gap) C++17
30 / 100
34 ms 2240 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e18;
ll a[100100];
int n;
ll mx = 1;
void play(ll l, ll r) {
	if (r - l <= mx) return;
	ll mid = (l + r) / 2;
	ll ql = -1, qr = -1, _l = -1, _r = -1;
	if (l + 1 <= mid) MinMax(l + 1, mid, &_l, &ql);
	if (mid + 1 <= r - 1) MinMax(mid + 1, r - 1, &qr, &_r);
	if (ql == -1 && qr == -1) return;
	if (ql == -1) {
		mx = max(mx, r - _r);
		return play(qr, _r);
	}
	if (qr == -1) {
		mx = max(mx, _l - l);
		return play(_l, ql);
	}
	if (ql != -1 && qr != -1) {
		mx = max(mx, r - _r);
		mx = max(mx, _l - l);
		mx = max(mx, qr - ql);
		play(_l, ql), play(qr, _r);
	}
}
ll findGap(int T, int N) {
	n = N;
	if (T == 1) {
		a[0] = -1, a[n + 1] = inf + 1;
		for (int i = 1;i <= n / 2;i++) {
			MinMax(a[i - 1] + 1, a[n - i + 2] - 1, &a[i], &a[n - i + 1]);
		}
		if (n & 1) {
			ll _;
			MinMax(a[n / 2] + 1, a[n / 2 + 2] - 1, &a[n / 2 + 1], &_);
		}
		for (int i = 1;i < n;i++) {
			mx = max(mx, a[i + 1] - a[i]);
		}
		return mx;
	}
	ll l, r;
	MinMax(0, inf, &l, &r);
	play(l, r);
	return mx;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 7 ms 812 KB Output is correct
17 Correct 7 ms 644 KB Output is correct
18 Correct 7 ms 644 KB Output is correct
19 Correct 7 ms 652 KB Output is correct
20 Correct 6 ms 632 KB Output is correct
21 Correct 30 ms 1976 KB Output is correct
22 Correct 28 ms 2240 KB Output is correct
23 Correct 33 ms 1980 KB Output is correct
24 Correct 28 ms 1896 KB Output is correct
25 Correct 25 ms 1952 KB Output is correct
26 Correct 28 ms 1980 KB Output is correct
27 Correct 28 ms 1868 KB Output is correct
28 Correct 29 ms 1844 KB Output is correct
29 Correct 32 ms 1940 KB Output is correct
30 Correct 23 ms 1952 KB Output is correct
31 Correct 1 ms 592 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Partially correct 0 ms 344 KB Partially correct
6 Partially correct 0 ms 344 KB Partially correct
7 Partially correct 0 ms 344 KB Partially correct
8 Incorrect 0 ms 344 KB Output isn't correct
9 Partially correct 0 ms 596 KB Partially correct
10 Correct 1 ms 344 KB Output is correct
11 Incorrect 1 ms 340 KB Output isn't correct
12 Incorrect 1 ms 344 KB Output isn't correct
13 Incorrect 1 ms 344 KB Output isn't correct
14 Partially correct 1 ms 344 KB Partially correct
15 Partially correct 1 ms 344 KB Partially correct
16 Partially correct 6 ms 644 KB Partially correct
17 Partially correct 6 ms 644 KB Partially correct
18 Partially correct 5 ms 644 KB Partially correct
19 Partially correct 6 ms 624 KB Partially correct
20 Correct 2 ms 624 KB Output is correct
21 Partially correct 20 ms 1208 KB Partially correct
22 Partially correct 21 ms 1216 KB Partially correct
23 Partially correct 20 ms 1212 KB Partially correct
24 Partially correct 22 ms 1464 KB Partially correct
25 Partially correct 34 ms 1192 KB Partially correct
26 Partially correct 22 ms 1232 KB Partially correct
27 Partially correct 23 ms 1188 KB Partially correct
28 Partially correct 21 ms 1212 KB Partially correct
29 Partially correct 21 ms 1208 KB Partially correct
30 Correct 7 ms 1192 KB Output is correct
31 Incorrect 0 ms 344 KB Output isn't correct
32 Incorrect 1 ms 344 KB Output isn't correct