Submission #838572

# Submission time Handle Problem Language Result Execution time Memory
838572 2023-08-27T12:02:00 Z tch1cherin Gap (APIO16_gap) C++17
30 / 100
32 ms 3060 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

long long findGap(int T, int N) {
	if (T == 1) {
		long long Min = -1, Max = 1e18l + 1;
		vector<long long> front, back;
		for (int i = 0; i < (N + 1) / 2; i++) {
			MinMax(Min + 1, Max - 1, &Min, &Max);
			if (Min != Max) {
				front.push_back(Min);
			}
			back.push_back(Max);
		}
		reverse(back.begin(), back.end());
		vector<long long> A;
		for (auto v : front) {
			A.push_back(v);
		}
		for (auto v : back) {
			A.push_back(v);
		}
		long long gap = 0;
		for (int i = 0; i < N - 1; i++) {
			gap = max(gap, A[i + 1] - A[i]);
		}
		return gap;
	} else {
		long long Min, Max;
		MinMax(0, 1e18, &Min, &Max);
		queue<pair<long long, long long>> Q;
		Q.push({Min, Max});
		long long maxConfirmed = (Max - Min + N - 2) / (N - 1);
		uniform_real_distribution<long double> dist(0, 1);
		mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());
		while (!Q.empty()) {
			auto [l, r] = Q.front();
			Q.pop();
			if (r - l <= maxConfirmed) {
				continue;
			}
			long long Minl = -1, Maxl = -1, Minr = -1, Maxr = -1;
			int children = 2;
			for (int i = 0; i < children; i++) {
				long long start = min(r, (long long)floorl(l + (r - l + 3) * ((1.0l / children) * i)));
				long long end = min(r, (long long)floorl(l + (r - l + 3) * ((1.0l / children) * (i + 1))) - 1);
				if (start > end) {
					continue;
				}
				MinMax(start, end, &Minr, &Maxr);
				if (Minr != -1) {
					if (Maxl != -1) { 
						maxConfirmed = max(maxConfirmed, Minr - Maxl);
					}
					Minl = Minr;
					Maxl = Maxr;
					Q.push({Maxl, Maxr});
				}
			}
		}
		return maxConfirmed;
	}
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:43:14: warning: variable 'Minl' set but not used [-Wunused-but-set-variable]
   43 |    long long Minl = -1, Maxl = -1, Minr = -1, Maxr = -1;
      |              ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 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 1 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 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 8 ms 1104 KB Output is correct
17 Correct 7 ms 1168 KB Output is correct
18 Correct 7 ms 1104 KB Output is correct
19 Correct 7 ms 1104 KB Output is correct
20 Correct 8 ms 1188 KB Output is correct
21 Correct 28 ms 3020 KB Output is correct
22 Correct 32 ms 2932 KB Output is correct
23 Correct 29 ms 3060 KB Output is correct
24 Correct 29 ms 3012 KB Output is correct
25 Correct 27 ms 3060 KB Output is correct
26 Correct 29 ms 3060 KB Output is correct
27 Correct 29 ms 2924 KB Output is correct
28 Correct 28 ms 3012 KB Output is correct
29 Correct 30 ms 3012 KB Output is correct
30 Correct 30 ms 3048 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 Incorrect 0 ms 208 KB Output isn't correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Incorrect 0 ms 208 KB Output isn't correct
7 Incorrect 0 ms 208 KB Output isn't correct
8 Incorrect 0 ms 208 KB Output isn't correct
9 Incorrect 0 ms 208 KB Output isn't correct
10 Incorrect 0 ms 208 KB Output isn't correct
11 Incorrect 1 ms 336 KB Output isn't correct
12 Incorrect 1 ms 208 KB Output isn't correct
13 Incorrect 1 ms 336 KB Output isn't correct
14 Incorrect 1 ms 208 KB Output isn't correct
15 Correct 1 ms 336 KB Output is correct
16 Incorrect 3 ms 464 KB Output isn't correct
17 Incorrect 5 ms 464 KB Output isn't correct
18 Incorrect 3 ms 464 KB Output isn't correct
19 Incorrect 3 ms 464 KB Output isn't correct
20 Incorrect 2 ms 464 KB Output isn't correct
21 Incorrect 13 ms 1016 KB Output isn't correct
22 Incorrect 13 ms 1104 KB Output isn't correct
23 Incorrect 12 ms 1088 KB Output isn't correct
24 Incorrect 19 ms 1004 KB Output isn't correct
25 Correct 16 ms 1104 KB Output is correct
26 Incorrect 12 ms 1072 KB Output isn't correct
27 Incorrect 12 ms 976 KB Output isn't correct
28 Incorrect 13 ms 976 KB Output isn't correct
29 Incorrect 13 ms 1060 KB Output isn't correct
30 Incorrect 7 ms 1048 KB Output isn't correct
31 Correct 0 ms 208 KB Output is correct
32 Incorrect 1 ms 228 KB Output isn't correct