제출 #89423

#제출 시각아이디문제언어결과실행 시간메모리
89423Good콤보 (IOI18_combo)C++11
100 / 100
47 ms636 KiB
#include "combo.h" #include <algorithm> using namespace std; std::string guess_sequence(int N) { /*std::string p = ""; for (int i = 0; i < 4 * N; ++i) { p += 'A'; } int coins = press(p); std::string S = ""; for (int i = 0; i < N; ++i) { S += 'A'; } return S;*/ int n = N; string s = ""; string ans = ""; s = "AB"; int a = press (s); if (a == 2) ans += 'A'; else if (a == 1) { a = press ("A"); if (a == 1) ans += 'A'; else ans += 'B'; } else { a = press ("X"); if (a == 1) ans += 'X'; else ans += 'Y'; } char b = ans[0]; for (int i = 2; i < n; i++) { int x = ans.size(); s = ""; if (b == 'A') { s += ans + "BX", s += ans + "BY", s += ans + "BB", s += ans + "X"; a = press (s); if (a == x + 2) ans += 'B'; else if (a == x + 1) ans += 'X'; else ans += 'Y'; } if (b == 'B') { s += ans + "AX", s += ans + "AY", s += ans + "AA", s += ans + "X"; a = press (s); if (a == x + 2) ans += 'A'; else if (a == x + 1) ans += 'X'; else ans += 'Y'; } if (b == 'X') { s += ans + "BA", s += ans + "BY", s += ans + "BB", s += ans + "A"; a = press (s); if (a == x + 2) ans += 'B'; else if (a == x + 1) ans += 'A'; else ans += 'Y'; } if (b == 'Y') { s += ans + "BX", s += ans + "BA", s += ans + "BB", s += ans + "X"; a = press (s); if (a == x + 2) ans += 'B'; else if (a == x + 1) ans += 'X'; else ans += 'A'; } } if (n > 1) { int x = ans.size(); s = ans + 'A' + ans + 'B'; a = press (s); if (a == x + 1) { s = ans + 'A'; a = press (s); if (a == x + 1) ans += 'A'; else ans += 'B'; } else { s = ans + 'X'; a = press (s); if (a == x + 1) ans += 'X'; else ans += 'Y'; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...