Submission #149378

#TimeUsernameProblemLanguageResultExecution timeMemory
149378Ian and 2-bit memory (#200)Lokahian Relics (FXCUP4_lokahia)C++17
0 / 100
12 ms728 KiB
#include <bits/stdc++.h>

using namespace std;


#include "lokahia.h"

int FindBase(int N){
if (N == 1)
	return 0;
srand(123);
	int left = 600 - (N - 1);
	int old = left;
	map<int, int> m;
	while (left) {
		int ta = rand() % N;
		int tb = rand() % N;
		if (left * 2 < old && !m.empty()) {
			int tc = rand() % m.size();
			auto it = m.begin();
			while (tc--)it++;
			ta = it->first;
		}
		if (ta == tb) continue;
		// printf("%d  %d %d\n", ++tmp, ta, tb);
		int tc = CollectRelics(ta, tb);
		if (tc != -1)
		m[tc]++;
		left--;
	}
	int ans = -1, ma = -1;
	//for (auto& i : m) printf("%d %d\n", i.first, i.second);
	for (auto& i : m)
		if (i.second >= ma) {
			ans = i.first;
			ma = i.second;
		}
	// printf("%d %d\n", ans, ma);
	if (ans == -1)
		return ans;
	ma = 1;
	for (int i = 0; i < N; i++)
		if (i != ans) {
			int ta = CollectRelics(i, ans);
			if (ta <= ans && ta != -1) {
				ma++;
				ans = ta;
			}
		}
	if (ma > N / 2)
		return ans;
	return -1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...