Submission #1318788

#TimeUsernameProblemLanguageResultExecution timeMemory
1318788tkm_algorithmsCombo (IOI18_combo)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;
using ll = long long;
// #define int ll
using P = pair<int, int>;
#define all(x) x.begin(), x.end()
#define rep(i, l, n) for (int i = l; i < (n); ++i)
#define sz(x) (int)x.size()
const char nl = '\n';

string guess_sequence(int n) {
	string p;
	int x = press("AB");
	if (x == 1) {
		if (press("A"))p += 'A';
		else p += 'B';
	} else {
		if (press("X"))p += 'X';
		else p += 'Y';
	}
	
	if (n == 1)return p;
	
	char a, b, c;
	if (p[0] == 'A')a = 'B', b = 'X', c = 'Y';
	else if (p[0] == 'B')a = 'A', b = 'X', c = 'Y';
	else if (p[0] == 'X')a = 'A', b = 'B', c = 'Y';
	else a = 'A', b = 'B', c = 'X';
	
	rep(i, 2, n) {
		x = press(p+a+p+b+a+p+b+c+p+b+b);
		if (x == i)p += a;
		else if (x == i+1)p += b;
		else p += c;
	}
	
	x = press(p+a+p+b);
	if (x == n) {
		if (press(p+a) == n)return p+a;
		else return p+b;
	} else return p+c;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...