Submission #413630

#TimeUsernameProblemLanguageResultExecution timeMemory
413630_fractalCombo (IOI18_combo)C++14
97 / 100
46 ms724 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

mt19937 bruh(chrono::steady_clock().now().time_since_epoch().count());

string guess_sequence(int N) {
	string A = "ABXY", a1;
	string p = "";
	shuffle(A.begin(), A.end(), bruh);

	for (auto c : A) {
		p = c;
		if (c == A[3] || press(p) == 1)
			break;
	}
	for (auto c : A)
		if (c != p[0])
			a1 += c;
	A = a1;
	for (int i = 1; i < N; ++i) {
		shuffle(A.begin(), A.end(), bruh);
		int pref = i;
		if (i + 2 <= N) {
			string a = p + A[0] + A[0];
			string b = p + A[0] + A[1];
			string c = p + A[0] + A[2];
			string d = p + A[1];
			int cnt = press(a + b + c + d) - pref;
			if (cnt == 2) {
				p += A[0];
			}
			else if (cnt == 1) {
				p += A[1];
			}
			else {
				p += A[2];
			}
		}
		else {
			if (press(p + A[0]) - pref == 1)
				p += A[0];
			else if (press(p + A[1]) - pref == 1)
				p += A[1];
			else
				p += A[2];
		}

	}
	return p;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...