제출 #362153

#제출 시각아이디문제언어결과실행 시간메모리
362153penguinhacker콤보 (IOI18_combo)C++14
100 / 100
53 ms548 KiB
#include <string> #include <vector> #include <assert.h> using namespace std; int press(string p); string guess_sequence(int n) { string ans; if (press("AB") > 0) { if (press("A")) ans = "A"; else ans = "B"; } else { if (press("X")) ans = "X"; else ans = "Y"; } assert((int)ans.size() == 1); if (n == 1) return ans; vector<char> v; if (ans != "A") v.push_back('A'); if (ans != "B") v.push_back('B'); if (ans != "X") v.push_back('X'); if (ans != "Y") v.push_back('Y'); assert(v.size() == 3); for (int i = 1; i < n - 1; ++i) { string s = ans + v[0] + v[0] + ans + v[0] + v[1] + ans + v[0] + v[2] + ans + v[1]; assert((int)s.size() <= 4 * n); int x = press(s); if (x == i) ans += v[2]; else if (x == i + 1) ans += v[1]; else if (x == i + 2) ans += v[0]; else assert(0); } assert((int)ans.size() == n - 1); if (press(ans + v[0]) == n) ans += v[0]; else if (press(ans + v[1]) == n) ans += v[1]; else ans += v[2]; assert((int)ans.size() == n); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...