제출 #674092

#제출 시각아이디문제언어결과실행 시간메모리
674092Nahian9696콤보 (IOI18_combo)C++17
100 / 100
34 ms536 KiB
#include "combo.h" #include <vector> using namespace std; vector<string> chars(3); vector<string> cur(3); std::string guess_sequence(int N) { string ans; int coin = press("AB"); if(coin == 0) { coin = press("X"); if(coin == 0) { ans = "Y"; chars = {"A", "B", "X"}; } else { ans = "X"; chars = {"A", "B", "Y"}; } } else { coin = press("A"); if(coin == 0) { ans = "B"; chars = {"A", "Y", "X"}; } else { ans = "A"; chars = {"Y", "B", "X"}; } } if(N == 1) return ans; cur = {ans+chars[0], ans+chars[1], ans+chars[2]}; int sz = 2; while(sz < N) { coin = press(cur[0] + chars[0] + cur[1] + chars[1] + cur[0] + chars[1]); if(coin == sz + 1) { cur = {cur[0] + chars[0], cur[1] + chars[1], cur[0] + chars[1]}; } else if (coin == sz) { cur = {cur[0] + chars[2], cur[1] + chars[0], cur[1] + chars[2]}; } else if (coin == sz - 1) { cur = {cur[2] + chars[0], cur[2] + chars[1], cur[2] + chars[2]}; } sz++; } coin = press(cur[0]); if(coin == sz) { ans = cur[0]; } else { coin = press(cur[1]); if(coin == sz) { ans = cur[1]; } else { ans = cur[2]; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...