Submission #561500

# Submission time Handle Problem Language Result Execution time Memory
561500 2022-05-13T01:54:50 Z hollwo_pelw Gap (APIO16_gap) C++17
100 / 100
47 ms 1104 KB
#include <bits/stdc++.h>
#include "gap.h"
 
using namespace std;
 
long long solve(int N) {
	long long l, r, res = 0;
	MinMax(0, 1e18, &l, &r);
 
	for (int i = 1; i <= (N - 1) / 2; i++) {
		long long nl, nr;
		MinMax(l + 1, r - 1, &nl, &nr);
 
		res = max(res, nl - l), l = nl;
		res = max(res, r - nr), r = nr;
	}
 
	return max(res, r - l);
}
 
long long findGap(int T, int N) {
	if (T == 1)
		return solve(N);
 
	long long l, r;
	MinMax(0, 1e18, &l, &r);
 
	long long res = (r - l - 1) / (N - 1) + 1;
 
	for (long long nl, nr; l < r; l = nr) {
		MinMax(l + 1, l + res, &nl, &nr);
		if (nr != -1) continue ;
	
		MinMax(l + 1, l + (res + 1) * 2, &nl, &nr);
		while (nl == -1) {
			res = (res + 1) * 2 + 1;
			MinMax(l + 1, l + (res + 1) * 2, &nl, &nr);
		}
		res = nl - l;
	}
 
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 356 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 10 ms 516 KB Output is correct
17 Correct 9 ms 544 KB Output is correct
18 Correct 10 ms 464 KB Output is correct
19 Correct 9 ms 464 KB Output is correct
20 Correct 7 ms 464 KB Output is correct
21 Correct 43 ms 1060 KB Output is correct
22 Correct 37 ms 1056 KB Output is correct
23 Correct 35 ms 1048 KB Output is correct
24 Correct 37 ms 1084 KB Output is correct
25 Correct 34 ms 1084 KB Output is correct
26 Correct 40 ms 1060 KB Output is correct
27 Correct 36 ms 1088 KB Output is correct
28 Correct 37 ms 1088 KB Output is correct
29 Correct 41 ms 1032 KB Output is correct
30 Correct 30 ms 968 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 280 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 8 ms 464 KB Output is correct
17 Correct 8 ms 464 KB Output is correct
18 Correct 6 ms 508 KB Output is correct
19 Correct 7 ms 464 KB Output is correct
20 Correct 3 ms 464 KB Output is correct
21 Correct 27 ms 1088 KB Output is correct
22 Correct 24 ms 1068 KB Output is correct
23 Correct 24 ms 972 KB Output is correct
24 Correct 26 ms 1088 KB Output is correct
25 Correct 47 ms 1088 KB Output is correct
26 Correct 25 ms 1044 KB Output is correct
27 Correct 25 ms 1064 KB Output is correct
28 Correct 25 ms 968 KB Output is correct
29 Correct 25 ms 1052 KB Output is correct
30 Correct 17 ms 1104 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct