제출 #709808

#제출 시각아이디문제언어결과실행 시간메모리
709808Cyanmond콤보 (IOI18_combo)C++17
100 / 100
37 ms580 KiB
#include "combo.h" #include <bits/stdc++.h> std::string guess_sequence(int N) { char firstC; if (press("AB") >= 1) { if (press("A") == 1) { firstC = 'A'; } else { firstC = 'B'; } } else { if (press("X") == 1) { firstC = 'X'; } else { firstC = 'Y'; } } if (N == 1) { std::string res = ""; res += firstC; return res; } std::vector<char> cs = {'A', 'B', 'X', 'Y'}; for (int i = 0; i < 4; ++i) { if (cs[i] == firstC) { cs.erase(cs.begin() + i); break; } } std::string answer = ""; answer += firstC; for (int i = 1; i < N - 1; ++i) { std::string x = answer; x += cs[1]; x += answer; x += cs[0]; x += cs[0]; x += answer; x += cs[0]; x += cs[1]; x += answer; x += cs[0]; x += cs[2]; const auto res = press(x); if (res == i) { answer += cs[2]; } else if (res == i + 1) { answer += cs[1]; } else { answer += cs[0]; } } if (press(answer + 'A' + answer + 'B') == N) { if (press(answer + 'A') == N) { answer += 'A'; } else { answer += 'B'; } } else { if (press(answer + 'X') == N) { answer += 'X'; } else { answer += 'Y'; } } return answer; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...