Submission #1020207

#TimeUsernameProblemLanguageResultExecution timeMemory
1020207CodeAssignmentCombo (IOI18_combo)C++17
0 / 100
0 ms344 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define trav(a, x) for (auto &a : x)
#define pb push_back
#define dbg(x) cout << #x << " = " << x << endl
//#define dbg(x) 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

string guess_sequence(int N) {
	ll n = N;
	vector<char> l = {'A', 'B', 'X', 'Y'};

	int coin;
	auto query = [&](string q) -> void {
		//dbg(q);
		coin = press(q);
	};

	string s = "Y";
	rep(i, 0, sz(l) - 1) {
		query(string(n, l[i]));
		if (coin > 0) {
			s = "";
			s += l[i];
			break;
		}
	}
	char st = s[0];
	
	dbg(st);
	dbg("step 1 done");
	vector<char> chars;
	trav(c, l) if (c != st) chars.pb(c);

	assert(sz(chars) == 3);
	rep(i, 0, n-1) {
		shuffle(all(chars), rnd);
		rep(j, 0, 3) {
			dbg(chars[j]);
		}
		bool found = 0;
		rep(j, 0, 2) {
			string temp = s;
			temp += chars[j];
			while(sz(temp) < n) temp += st;
			query(temp);
			if (coin == sz(s) + 1) {
				s += chars[j];
				found = 1;
				break;
			}
		}
		if (!found) s += chars[2];
	}
	return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...