Submission #1085043

# Submission time Handle Problem Language Result Execution time Memory
1085043 2024-09-07T11:53:03 Z Timosh Gap (APIO16_gap) C++17
42.8822 / 100
65 ms 5912 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;

long long mn = 0, mx = 0;
set<long long> st;
void gen(long long l, long long r)
{
	if (l > r)
		return;
	MinMax(l, r, &mn, &mx);
	if (mn == -1)
		return;
	st.insert(mn);
	st.insert(mx);
	if (mn == mx)
		return;
	l = mn + 1, r = mx - 1;
	long long m = l + (r - l) / 2;
	gen(l, m);
	gen(m + 1, r);
}

long long findGap(int T, int N)
{
	long long ans = 1;
	if (T == 2)
	{
		gen(0, 1e18);
	}
	else
	{
		long long l = 0, r = 1e18;
		while (1)
		{
			MinMax(l, r, &mn, &mx);
			if (mn == -1)
				break;
			st.insert(mn);
			st.insert(mx);
			l = mn + 1, r = mx - 1;
			if (mn == mx || st.size() >= N)
				break;
		}
	}
	long long last = *st.begin();
	for (auto &i : st)
		ans = max(ans, i - last), last = i;
	return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:42:30: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |    if (mn == mx || st.size() >= N)
      |                    ~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 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 9 ms 1716 KB Output is correct
17 Correct 9 ms 1624 KB Output is correct
18 Correct 9 ms 1624 KB Output is correct
19 Correct 11 ms 1624 KB Output is correct
20 Correct 8 ms 1624 KB Output is correct
21 Correct 39 ms 5720 KB Output is correct
22 Correct 43 ms 5712 KB Output is correct
23 Correct 41 ms 5912 KB Output is correct
24 Correct 41 ms 5712 KB Output is correct
25 Correct 37 ms 5712 KB Output is correct
26 Correct 44 ms 5712 KB Output is correct
27 Correct 42 ms 5900 KB Output is correct
28 Correct 48 ms 5712 KB Output is correct
29 Correct 42 ms 5900 KB Output is correct
30 Correct 37 ms 5808 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Partially correct 0 ms 344 KB Partially correct
3 Partially correct 0 ms 344 KB Partially correct
4 Partially correct 0 ms 344 KB Partially correct
5 Partially correct 0 ms 344 KB Partially correct
6 Partially correct 0 ms 344 KB Partially correct
7 Partially correct 1 ms 344 KB Partially correct
8 Partially correct 0 ms 344 KB Partially correct
9 Partially correct 0 ms 344 KB Partially correct
10 Partially correct 0 ms 344 KB Partially correct
11 Partially correct 1 ms 344 KB Partially correct
12 Partially correct 1 ms 344 KB Partially correct
13 Partially correct 1 ms 344 KB Partially correct
14 Partially correct 1 ms 344 KB Partially correct
15 Partially correct 1 ms 344 KB Partially correct
16 Partially correct 12 ms 1732 KB Partially correct
17 Partially correct 12 ms 1624 KB Partially correct
18 Partially correct 12 ms 1624 KB Partially correct
19 Partially correct 13 ms 1740 KB Partially correct
20 Partially correct 10 ms 1624 KB Partially correct
21 Partially correct 48 ms 5792 KB Partially correct
22 Partially correct 51 ms 5732 KB Partially correct
23 Partially correct 58 ms 5712 KB Partially correct
24 Partially correct 65 ms 5712 KB Partially correct
25 Partially correct 49 ms 5804 KB Partially correct
26 Partially correct 55 ms 5712 KB Partially correct
27 Partially correct 48 ms 5720 KB Partially correct
28 Partially correct 49 ms 5712 KB Partially correct
29 Partially correct 53 ms 5712 KB Partially correct
30 Partially correct 43 ms 5712 KB Partially correct
31 Partially correct 0 ms 344 KB Partially correct
32 Partially correct 0 ms 344 KB Partially correct