제출 #310802

#제출 시각아이디문제언어결과실행 시간메모리
310802jjjjj19980806콤보 (IOI18_combo)C++14
100 / 100
49 ms708 KiB
#include "combo.h" #include <iostream> #include <vector> #include <algorithm> using namespace std; string guess_sequence(int N) { // int coins = press(p); string beg; if (press("AB") >= 1) { beg = press("A") == 1 ? 'A' : 'B'; } else { beg = press("X") == 1 ? 'X' : 'Y'; } if (N == 1) return beg; vector<string> dict{"A", "B", "X", "Y"}; dict.erase(find(dict.begin(), dict.end(), beg)); string ans = beg; for (int i = 1; i < N - 1; i++) { string p = ans; string guess = (p + dict[1]); for (auto d : dict) { guess += (p + dict[2] + d); } int res = press(guess); if (res == i) { ans += dict[0]; } else if (res == i + 1) { ans += dict[1]; } else { ans += dict[2]; } } for (int j = 0; j < 2; j++) { if (press(ans + dict[j]) == N) { return ans + dict[j]; } } return ans + dict[2]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...