제출 #1201040

#제출 시각아이디문제언어결과실행 시간메모리
1201040waigoon콤보 (IOI18_combo)C++20
5 / 100
0 ms408 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string ans; int first = press("AB"); if (first == 2) ans = "AB"; else if (first == 1) { int res = press("BA"); if (res == 2) ans = "BA"; else { int l = press("AXAY"); if (l == 2) ans = (press("AX") == 2 ? "AX" : "AY"); else ans = (press("BX") == 2 ? "BX" : "BY"); } } else { int res = press("X"); if (res == 1) { int l = (press("XAXB")); if (l == 2) ans = (press("XA") == 2 ? "XA" : "XB"); else ans = "XY"; } else { int l = press("YAYB"); if (l == 2) ans = (press("YA") == 2 ? "YA" : "YB"); else ans = "YX"; } } int t; if (ans[0] == 'A') t = 0; else if (ans[0] == 'B') t = 1; else if (ans[0] == 'X') t = 2; else t = 3; string st = "ABXY"; for (int i = 2; i < N-1; i += 2) { string g1 = ans + st[(t+1)%4] + st[(t+2)%4]; string g2 = ans + st[(t+2)%4] + st[(t+3)%4]; int res = press(g1+g2); if (res == (int)ans.length() + 1) { int l = press(g1); if (l == (int)ans.length() + 1) ans += st[(t+1)%4] + st[(t+3)%4]; else ans += st[(t+2)%4] + st[(t+1)%4]; } else if (res == (int)ans.length() + 2) { int l = press(g1); if (l == (int)ans.length() + 2) ans = g1; else ans = g2; } else { string g3 = ans + st[(t+3)%4] + st[(t+1)%4]; int l = press(g3); if (l == (int)ans.length() + 1) ans += st[(t+3)%4] + st[(t+2)%4]; else ans = g3; } } if (ans.size() != N) { int res = press(ans + st[(t+1)%4]); if (res == N) ans += st[(t+1)%4]; else ans += (press(ans + st[(t+2)%4]) == N ? st[(t+2)%4] : st[(t+3)%4]); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...