Submission #149701

# Submission time Handle Problem Language Result Execution time Memory
149701 2019-09-01T06:59:27 Z Ian and 2-bit memory(#3648, percywtc, nhho, ulna) Lokahian Relics (FXCUP4_lokahia) C++17
0 / 100
31 ms 768 KB
#include <bits/stdc++.h>

using namespace std;

#include "lokahia.h"

int FindBase(int N){
	if (N == 1)
		return 0;
	srand(123);
	int left = 400 - N;
	vector<int> v(N, 1);
	map<pair<int, int>, int> m;
	int cnt = 0;
	while (left) {
		int hv = 0;
		for (int i = 0; i < N; i++)
			if (v[i])
				hv += max(50, v[i]);
		int ta = rand() % hv;
		for (int i = 0; i < N; i++) {
			if (!v[i])
				continue;
			if (ta < max(50, v[i])) {
				ta = i;
				hv -= max(50, v[i]);
				break;
			} else
				ta -= max(50, v[i]);
		}
		if (!hv)
			break;
		int tb = rand() % hv;
		for (int i = 0; i < N; i++) {
			if (!v[i] || i == ta)
				continue;
			if (tb < max(50, v[i])) {
				tb = i;
				break;
		} else
				tb -= max(50, v[i]);
		}
		if (ta > tb)
			swap(ta, tb);
		int tc;
		if (m.count({ta, tb})) {
			tc = m[{ta, tb}];
			cnt++;
			if (cnt == 500) {
				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) {
			int ta = CollectRelics(i, ans);
			if (ta == -1)
				continue;
			ma++;
			ans = ta;
		}
	if (ma > N / 2)
		return ans;
	return -1;
}
# Verdict Execution time Memory Grader output
1 Partially correct 9 ms 640 KB Partially correct : C = 399
2 Partially correct 6 ms 640 KB Partially correct : C = 399
3 Partially correct 6 ms 640 KB Partially correct : C = 399
4 Partially correct 7 ms 640 KB Partially correct : C = 399
5 Correct 6 ms 600 KB Correct : C = 182
6 Correct 31 ms 632 KB Correct : C = 239
7 Partially correct 7 ms 688 KB Partially correct : C = 399
8 Partially correct 7 ms 640 KB Partially correct : C = 399
9 Partially correct 6 ms 600 KB Partially correct : C = 399
10 Partially correct 7 ms 640 KB Partially correct : C = 399
11 Correct 5 ms 512 KB Correct : C = 0
12 Partially correct 6 ms 600 KB Partially correct : C = 304
13 Incorrect 8 ms 640 KB Wrong
14 Partially correct 7 ms 600 KB Partially correct : C = 399
15 Partially correct 8 ms 640 KB Partially correct : C = 399
16 Partially correct 6 ms 640 KB Partially correct : C = 399
17 Incorrect 7 ms 640 KB Wrong
18 Partially correct 7 ms 768 KB Partially correct : C = 399
19 Partially correct 7 ms 640 KB Partially correct : C = 306
20 Partially correct 18 ms 640 KB Partially correct : C = 344
21 Partially correct 6 ms 640 KB Partially correct : C = 399
22 Partially correct 6 ms 640 KB Partially correct : C = 399
23 Partially correct 7 ms 640 KB Partially correct : C = 399
24 Partially correct 6 ms 640 KB Partially correct : C = 399
25 Correct 5 ms 512 KB Correct : C = 7
26 Partially correct 7 ms 640 KB Partially correct : C = 399
27 Correct 6 ms 640 KB Correct : C = 180