# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1217985 | islam_2010 | 콤보 (IOI18_combo) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int n) {
string s;
vector<char> candidates = {'A', 'B', 'X', 'Y'};
string first_try = "AB";
if (press(first_try) == 1) {
if (press("A") == 1) {
s = "A";
candidates = {'B', 'X', 'Y'};
} else {
s = "B";
candidates = {'A', 'X', 'Y'};
}
} else {
if (press("X") == 1) {
s = "X";
candidates = {'A', 'B', 'Y'};
} else {
s = "Y";
candidates = {'A', 'B', 'X'};
}
}
while (s.size() < n) {
bool found = false;
for (char c : candidates) {
int res = press(s + c);
if (res == s.size() + 1) {
s += c;
found = true;
break;
}
}
if (!found && s.size() == n - 1) {
for (char c : candidates) {
if (press(s + c) == n) {
s += c;
break;
}
}
}
}
return s;
}