Submission #30809

# Submission time Handle Problem Language Result Execution time Memory
30809 2017-07-26T14:53:03 Z cdemirer Gap (APIO16_gap) C++14
30 / 100
2000 ms 14468 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> llp;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#include "gap.h"

set<ll> S;

ll subtask1(int N) {
	//cerr << N << endl;
	ll l = 0, r = 1e18+1;
	ll q, w;
	while (N > 0) {
		MinMax(l, r, &q, &w);
		//cerr << q << w << endl;
		S.insert(q); S.insert(w);
		l = q+1;
		r = w-1;
		N -= 2;
	}
	set<ll>::iterator it = S.begin();
	it++;
	ll best = 0;
	for (; it != S.end(); it++) {
		set<ll>::iterator it2 = it;
		it2--;
		best = max(best, (*it) - (*it2));
	}
	return best;
}

void func(ll l, ll r) {
	if (l > r) return;
	ll q, w;
	MinMax(l, r, &q, &w);
	if (q == -1) return;
	S.insert(q); S.insert(w);
	if (q == w) return;
	if (q == w-1) return;
	if (q == w-2) {
		func(q+1, q+1);
		return;
	}
	int mid = (q+w)/2;
	if (q+1 != mid) func(q+1, mid);
	if (mid != w-1) func(mid, w-1);
}

ll subtask2(int N) {
	func(0, 1e18);
	set<ll>::iterator it = S.begin();

	/*set<ll>::iterator dbgit = it;
	while (dbgit != S.end()) {
		cerr << *dbgit << endl;
		dbgit++;
	}*/


	it++;
	ll best = 0;
	for (; it != S.end(); it++) {
		set<ll>::iterator it2 = it;
		it2--;
		best = max(best, (*it) - (*it2));
	}
	return best;
}

long long findGap(int T, int N)
{
	if (T == 1) return subtask1(N);
	else return subtask2(N);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5148 KB Output is correct
2 Correct 0 ms 5148 KB Output is correct
3 Correct 0 ms 5148 KB Output is correct
4 Correct 0 ms 5148 KB Output is correct
5 Correct 0 ms 5148 KB Output is correct
6 Correct 0 ms 5148 KB Output is correct
7 Correct 0 ms 5148 KB Output is correct
8 Correct 0 ms 5148 KB Output is correct
9 Correct 0 ms 5148 KB Output is correct
10 Correct 0 ms 5148 KB Output is correct
11 Correct 0 ms 5280 KB Output is correct
12 Correct 0 ms 5280 KB Output is correct
13 Correct 0 ms 5280 KB Output is correct
14 Correct 0 ms 5280 KB Output is correct
15 Correct 0 ms 5280 KB Output is correct
16 Correct 19 ms 6336 KB Output is correct
17 Correct 23 ms 6336 KB Output is correct
18 Correct 19 ms 6336 KB Output is correct
19 Correct 23 ms 6336 KB Output is correct
20 Correct 16 ms 6336 KB Output is correct
21 Correct 89 ms 9900 KB Output is correct
22 Correct 89 ms 9900 KB Output is correct
23 Correct 93 ms 9900 KB Output is correct
24 Correct 103 ms 9900 KB Output is correct
25 Correct 79 ms 9900 KB Output is correct
26 Correct 96 ms 9900 KB Output is correct
27 Correct 103 ms 9900 KB Output is correct
28 Correct 96 ms 9900 KB Output is correct
29 Correct 79 ms 9900 KB Output is correct
30 Correct 76 ms 9900 KB Output is correct
31 Correct 0 ms 5148 KB Output is correct
32 Correct 0 ms 5148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5148 KB Output is correct
2 Partially correct 0 ms 5148 KB Partially correct
3 Partially correct 0 ms 5148 KB Partially correct
4 Partially correct 0 ms 5148 KB Partially correct
5 Partially correct 0 ms 5148 KB Partially correct
6 Partially correct 0 ms 5148 KB Partially correct
7 Partially correct 0 ms 5148 KB Partially correct
8 Partially correct 0 ms 5148 KB Partially correct
9 Partially correct 0 ms 5148 KB Partially correct
10 Partially correct 0 ms 5148 KB Partially correct
11 Partially correct 0 ms 5280 KB Partially correct
12 Partially correct 0 ms 5280 KB Partially correct
13 Partially correct 0 ms 5280 KB Partially correct
14 Partially correct 0 ms 5280 KB Partially correct
15 Partially correct 63 ms 5280 KB Partially correct
16 Partially correct 26 ms 7384 KB Partially correct
17 Partially correct 23 ms 7384 KB Partially correct
18 Partially correct 33 ms 7384 KB Partially correct
19 Partially correct 23 ms 7384 KB Partially correct
20 Partially correct 16 ms 6336 KB Partially correct
21 Incorrect 116 ms 14464 KB Expected int32, but "5000150000" found
22 Incorrect 116 ms 14464 KB Expected int32, but "5000150000" found
23 Incorrect 136 ms 14464 KB Expected int32, but "5000150000" found
24 Incorrect 116 ms 14464 KB Expected int32, but "5000150000" found
25 Execution timed out 2000 ms 9476 KB Execution timed out
26 Incorrect 99 ms 14460 KB Expected int32, but "5000150000" found
27 Incorrect 116 ms 14464 KB Expected int32, but "5000150000" found
28 Incorrect 129 ms 14460 KB Expected int32, but "5000150000" found
29 Incorrect 129 ms 14468 KB Expected int32, but "5000150000" found
30 Partially correct 96 ms 9900 KB Partially correct
31 Partially correct 0 ms 5148 KB Partially correct
32 Partially correct 0 ms 5148 KB Partially correct