제출 #228392

#제출 시각아이디문제언어결과실행 시간메모리
228392hhh07콤보 (IOI18_combo)C++14
100 / 100
38 ms628 KiB
#include <iostream> #include <string> #include <algorithm> #include "combo.h" using namespace std; string guess_sequence(int n){ string curr = ""; char x[4]; x[0] = 'A'; x[1] = 'B'; x[2] = 'X'; x[3] = 'Y'; if (press("AB") > 0){ if (press("A") > 0) curr = "A"; else curr = "B"; } else{ if (press("X") > 0) curr = "X"; else curr = "Y"; } for (int i = 0; i < 4; i++){ if (x[i] == curr[0]){ swap(x[i], x[3]); break; } } int t = 1; while(t < n){ if (t == n - 1){ if (press(curr + x[0]) == n) return curr + x[0]; if (press(curr + x[1]) == n) return curr + x[1]; return curr + x[2]; } string s = ""; for (int i = 0; i < 3; i++){ s += curr; s += x[0]; s += x[i]; } s += curr; s += x[1]; s += curr[0]; int res = press(s); if (res >= t + 2) curr += x[0]; else if (res >= t + 1) curr += x[1]; else curr += x[2]; t++; } return curr; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...