Submission #411489

#TimeUsernameProblemLanguageResultExecution timeMemory
411489Mlxa동굴 (IOI13_cave)C++14
51 / 100
2068 ms484 KiB
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
#define x first
#define y second

const int N = 5050;

int n;
int s[N];
int d[N];
mt19937 rnd;

int query() {
	int t = tryCombination(s);
	return t == -1 ? n : t;
}

void exploreCave(int nn) {
	n = nn;
	fill_n(d, N, -1);
	for (int i = 0; i < n; ++i) {
		vector<int> f;
		for (int j = 0; j < n; ++j) {
			if (d[j] == -1) {
				f.push_back(j);
			}
		}
		vector<int> can = f;
		int q = query();
		while (can.size() > 1) {
			// cout << can.size() << endl;
			vector<int> vec;
			for (int e : f) {
				if (rnd() % 2) {
					vec.push_back(e);
					s[e] ^= 1;
				}
			}
			int t = query();
			for (int e : vec) {
				s[e] ^= 1;
			}
			assert(q >= i && t >= i);
			if ((q == i) == (t == i)) {
				continue;
			}
			vector<int> temp;
			for (int e : can) {
				if (binary_search(all(vec), e)) {
					temp.push_back(e);
				}
			}
			can = temp;
		}
		d[can[0]] = i;
		assert(q >= i);
		if (q == i) {
			assert(can.size() == 1);
			s[can[0]] ^= 1;
		}
		assert(query() > i);
	}
	answer(s, d);
}




#ifdef LC
#include "graderlib.c"

int main() {
	N = init();
	exploreCave(N);
	printf("INCORRECT\nYour solution did not call answer().\n");
	return 0;
}
#endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...