제출 #1278672

#제출 시각아이디문제언어결과실행 시간메모리
1278672IBory콤보 (IOI18_combo)C++20
5 / 100
1 ms400 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int N) {
	string P = "ABXY";
	int n = press("AB");
	char c = ' ';
	if (n) c = (press("A") ? 'A' : 'B');
	else c = (press("X") ? 'X' : 'Y');
	P.erase(P.begin() + P.find(c));

	string S; S.push_back(c);
	string P1, P21, P22, P23;
	P1.push_back(P[0]);
	P21.push_back(P[1]); P21.push_back(P[0]);
	P22.push_back(P[1]); P22.push_back(P[1]);
	P23.push_back(P[1]); P23.push_back(P[2]);
	
	for (int i = 2; i < N; ++i) {
		string T = S + P1 + S + P21 + S + P22 + S + P23;
		int n = press(T);
		if (n == (i - 1)) S.push_back(P[2]);
		else if (n == i) S.push_back(P[0]);
		else S.push_back(P[1]);
	}

	for (int i = 0; i < 3; ++i) {
		S.push_back(P[i]);
		if (i == 2 || press(S) == N) return S;
		S.pop_back();
	}

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