Submission #30803

# Submission time Handle Problem Language Result Execution time Memory
30803 2017-07-26T14:47:39 Z cdemirer Gap (APIO16_gap) C++14
30 / 100
2000 ms 16028 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);
	int mid = (l+r)/2;
	func(q+1, mid);
	func(mid+1, 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 23 ms 6336 KB Output is correct
17 Correct 16 ms 6336 KB Output is correct
18 Correct 23 ms 6336 KB Output is correct
19 Correct 16 ms 6336 KB Output is correct
20 Correct 9 ms 6336 KB Output is correct
21 Correct 86 ms 9900 KB Output is correct
22 Correct 86 ms 9900 KB Output is correct
23 Correct 86 ms 9900 KB Output is correct
24 Correct 116 ms 9900 KB Output is correct
25 Correct 96 ms 9900 KB Output is correct
26 Correct 89 ms 9900 KB Output is correct
27 Correct 96 ms 9900 KB Output is correct
28 Correct 86 ms 9900 KB Output is correct
29 Correct 76 ms 9900 KB Output is correct
30 Correct 66 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 59 ms 5280 KB Partially correct
16 Partially correct 33 ms 7776 KB Partially correct
17 Partially correct 26 ms 7772 KB Partially correct
18 Partially correct 29 ms 7768 KB Partially correct
19 Partially correct 19 ms 7776 KB Partially correct
20 Partially correct 16 ms 6336 KB Partially correct
21 Incorrect 123 ms 16024 KB Expected int32, but "5000150001" found
22 Incorrect 133 ms 16028 KB Expected int32, but "5000150001" found
23 Incorrect 116 ms 16024 KB Expected int32, but "5000150001" found
24 Incorrect 116 ms 16024 KB Expected int32, but "5000150001" found
25 Execution timed out 2000 ms 8708 KB Execution timed out
26 Incorrect 129 ms 16024 KB Expected int32, but "5000150001" found
27 Incorrect 123 ms 16024 KB Expected int32, but "5000150001" found
28 Incorrect 123 ms 16024 KB Expected int32, but "5000150001" found
29 Incorrect 143 ms 16024 KB Expected int32, but "5000150001" found
30 Partially correct 93 ms 9900 KB Partially correct
31 Partially correct 0 ms 5148 KB Partially correct
32 Partially correct 0 ms 5148 KB Partially correct