Submission #149609

# Submission time Handle Problem Language Result Execution time Memory
149609 2019-09-01T06:49:53 Z Ian and 2-bit memory(#3648, percywtc, nhho, ulna) Lokahian Relics (FXCUP4_lokahia) C++17
51 / 100
8 ms 640 KB
#include <bits/stdc++.h>

using namespace std;

#include "lokahia.h"

int FindBase(int N){
	if (N == 1)
		return 0;
	srand(123);
	int left = 500 - (N - 1);
	vector<int> v(N, 1);
	map<pair<int, int>, int> m;
	int cnt = 0;
	while (left) {
		int hv = N;
		int ta = rand() % hv;
		for (int i = 0; i < N; i++) {
			if (!v[i])
				continue;
			if (ta < v[i]) {
				ta = i;
				hv -= v[i];
				break;
			} else
				ta -= v[i];
		}
		if (!hv)
			break;
		int tb = rand() % hv;
		for (int i = 0; i < N; i++) {
			if (!v[i] || i == ta)
				continue;
			if (tb < v[i]) {
				tb = i;
				hv -= v[i];
				break;
			} else
				tb -= v[i];
		}
		if (ta > tb)
			swap(ta, tb);
		int tc;
		if (m.count({ta, tb})) {
			tc = m[{ta, tb}];
			cnt++;
			if (cnt == 10) {
				cnt = 0;
				left--;
			}
		} else {
			m[{ta, tb}] = tc = CollectRelics(ta, tb);
			left--;
			cnt = 0;
		}
		if (tc != -1) {
			if (tc != ta) {
				v[tc] += v[ta];
				v[ta] = 0;
			}
			if (tc != tb) {
				v[tc] += v[tb];
				v[tb] = 0;
			}
		}
	}
	int ans = -1, ma = -1;
	for (int i = 0; i < N; i++)
		if (v[i] >= ma) {
			ma = v[i];
			ans = i;
		}
	if (ans == -1)
		return ans;
	ma = 1;
	for (int i = 0; i < N; i++)
		if (i != ans)
			ma += CollectRelics(i, ans) == ans;
	if (ma > N / 2)
		return ans;
	return -1;
}
# Verdict Execution time Memory Grader output
1 Partially correct 8 ms 640 KB Partially correct : C = 357
2 Partially correct 7 ms 640 KB Partially correct : C = 500
3 Partially correct 7 ms 640 KB Partially correct : C = 469
4 Partially correct 7 ms 496 KB Partially correct : C = 500
5 Partially correct 7 ms 640 KB Partially correct : C = 451
6 Correct 5 ms 440 KB Correct : C = 8
7 Partially correct 7 ms 640 KB Partially correct : C = 435
8 Partially correct 7 ms 512 KB Partially correct : C = 442
9 Partially correct 8 ms 640 KB Partially correct : C = 348
10 Partially correct 7 ms 640 KB Partially correct : C = 500
11 Partially correct 7 ms 640 KB Partially correct : C = 500
12 Partially correct 7 ms 640 KB Partially correct : C = 500
13 Correct 6 ms 512 KB Correct : C = 276
14 Correct 6 ms 640 KB Correct : C = 210
15 Partially correct 6 ms 512 KB Partially correct : C = 500
16 Partially correct 7 ms 640 KB Partially correct : C = 444
17 Partially correct 7 ms 640 KB Partially correct : C = 445
18 Correct 5 ms 512 KB Correct : C = 213
19 Partially correct 7 ms 640 KB Partially correct : C = 426
20 Correct 5 ms 384 KB Correct : C = 0
21 Partially correct 6 ms 640 KB Partially correct : C = 500
22 Partially correct 8 ms 640 KB Partially correct : C = 500
23 Partially correct 7 ms 640 KB Partially correct : C = 500
24 Partially correct 6 ms 640 KB Partially correct : C = 500
25 Partially correct 7 ms 640 KB Partially correct : C = 500
26 Partially correct 6 ms 512 KB Partially correct : C = 336
27 Partially correct 6 ms 640 KB Partially correct : C = 500