Submission #149589

# Submission time Handle Problem Language Result Execution time Memory
149589 2019-09-01T06:47:44 Z Ian and 2-bit memory(#3648, percywtc, nhho, ulna) Lokahian Relics (FXCUP4_lokahia) C++17
0 / 100
7 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 = 300 - (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 Correct 6 ms 512 KB Correct : C = 300
2 Correct 7 ms 640 KB Correct : C = 300
3 Correct 6 ms 636 KB Correct : C = 300
4 Correct 6 ms 640 KB Correct : C = 300
5 Correct 5 ms 512 KB Correct : C = 0
6 Correct 7 ms 640 KB Correct : C = 300
7 Correct 6 ms 640 KB Correct : C = 300
8 Incorrect 6 ms 640 KB Wrong
9 Correct 6 ms 640 KB Correct : C = 300
10 Correct 6 ms 640 KB Correct : C = 300
11 Correct 7 ms 640 KB Correct : C = 300
12 Correct 6 ms 512 KB Correct : C = 213
13 Correct 6 ms 640 KB Correct : C = 300
14 Correct 6 ms 512 KB Correct : C = 300
15 Correct 6 ms 640 KB Correct : C = 276
16 Correct 6 ms 640 KB Correct : C = 300
17 Correct 6 ms 640 KB Correct : C = 300
18 Correct 6 ms 640 KB Correct : C = 210
19 Correct 5 ms 640 KB Correct : C = 300
20 Correct 7 ms 640 KB Correct : C = 300
21 Correct 6 ms 640 KB Correct : C = 300
22 Correct 6 ms 600 KB Correct : C = 300
23 Correct 6 ms 512 KB Correct : C = 8
24 Incorrect 6 ms 640 KB Wrong
25 Correct 6 ms 640 KB Correct : C = 300
26 Correct 6 ms 640 KB Correct : C = 300
27 Correct 6 ms 640 KB Correct : C = 300