제출 #107283

#제출 시각아이디문제언어결과실행 시간메모리
107283wonyoung콤보 (IOI18_combo)C++14
100 / 100
50 ms576 KiB
#include <vector> #include <string> using namespace std; int press(string p); char binary_guess(string prefix, string cd) { int pn = prefix.length(); if (press(prefix + cd[0] + prefix + cd[1]) > pn) { if (press(prefix + cd[0]) > pn) return cd[0]; return cd[1]; } if (press(prefix + cd[2]) > pn) return cd[2]; return cd[3]; } string guess_sequence(int N) { string prefix; string buttons = "ABXY"; prefix += binary_guess("", buttons); buttons.erase(buttons.begin() + buttons.find(prefix[0])); if (N == 1) return prefix; int pn; while ((pn = prefix.length()) < N - 1) { string query_string; query_string += prefix + buttons[0]; for (int i=0; i<3; i++) query_string += prefix + buttons[1] + buttons[i]; int n = press(query_string); if (n == pn + 1) prefix += buttons[0]; else if (n == pn + 2) prefix += buttons[1]; else prefix += buttons[2]; } prefix += binary_guess(prefix, buttons); return prefix; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...