답안 #149654

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149654 2019-09-01T06:54:53 Z Ian and 2-bit memory(#3648, percywtc, nhho, ulna) 로카히아 유적 (FXCUP4_lokahia) C++17
0 / 100
7 ms 696 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 - 1);
	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(5, v[i]);
		int ta = rand() % hv;
		for (int i = 0; i < N; i++) {
			if (!v[i])
				continue;
			if (ta < max(5, v[i])) {
				ta = i;
				hv -= max(5, v[i]);
				break;
			} else
				ta -= max(5, 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(5, v[i])) {
				tb = i;
				break;
			} else
				tb -= max(5, v[i]);
		}
		if (ta > tb)
			swap(ta, tb);
		int tc;
		if (m.count({ta, tb})) {
			tc = m[{ta, tb}];
			cnt++;
			if (cnt == 20) {
				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;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 6 ms 640 KB Partially correct : C = 400
2 Correct 6 ms 512 KB Correct : C = 194
3 Partially correct 7 ms 640 KB Partially correct : C = 400
4 Correct 6 ms 492 KB Correct : C = 7
5 Partially correct 6 ms 640 KB Partially correct : C = 400
6 Partially correct 7 ms 640 KB Partially correct : C = 400
7 Partially correct 7 ms 640 KB Partially correct : C = 336
8 Correct 6 ms 512 KB Correct : C = 0
9 Partially correct 7 ms 696 KB Partially correct : C = 400
10 Partially correct 6 ms 640 KB Partially correct : C = 400
11 Partially correct 6 ms 640 KB Partially correct : C = 400
12 Partially correct 7 ms 640 KB Partially correct : C = 400
13 Partially correct 6 ms 640 KB Partially correct : C = 400
14 Partially correct 6 ms 640 KB Partially correct : C = 400
15 Correct 6 ms 512 KB Correct : C = 278
16 Incorrect 7 ms 640 KB Wrong
17 Partially correct 6 ms 640 KB Partially correct : C = 400
18 Partially correct 7 ms 640 KB Partially correct : C = 400
19 Partially correct 7 ms 640 KB Partially correct : C = 400
20 Correct 5 ms 512 KB Correct : C = 196
21 Partially correct 7 ms 640 KB Partially correct : C = 400
22 Partially correct 7 ms 640 KB Partially correct : C = 400
23 Partially correct 7 ms 640 KB Partially correct : C = 400
24 Partially correct 7 ms 640 KB Partially correct : C = 325
25 Partially correct 6 ms 640 KB Partially correct : C = 400
26 Partially correct 7 ms 512 KB Partially correct : C = 400
27 Partially correct 6 ms 640 KB Partially correct : C = 329