제출 #528129

#제출 시각아이디문제언어결과실행 시간메모리
528129happypotato콤보 (IOI18_combo)C++17
100 / 100
38 ms684 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { const string valid = "ABXY"; char fir; string ans = ""; if (press("AB")) { if (press("AX")) fir = 'A'; else fir = 'B'; } else { if (press("AX")) fir = 'X'; else fir = 'Y'; } ans += fir; if (N == 1) return ans; for (int i = 1; i < N - 1; i++) { string req = ""; int cnt = 0; for (int j = 0; j < 4; j++) { if (valid[j] == fir) continue; cnt++; if (cnt == 1) continue; else if (cnt == 2) { req += ans + valid[j]; } else { for (int k = 0; k < 4; k++) { if (valid[k] == fir) continue; req += ans + valid[j] + valid[k]; } } } int res = press(req) - i; for (int j = 0; j < 4; j++) { if (valid[j] == fir) continue; if (res == 0) { ans += valid[j]; break; } res--; } } int cnt = 0; for (int i = 0; i < 4; i++) { if (valid[i] == fir) continue; string tar = ans + valid[i]; if (cnt == 2) return tar; if (press(tar) == N) return tar; cnt++; } return ""; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...