제출 #587968

#제출 시각아이디문제언어결과실행 시간메모리
587968vilji콤보 (IOI18_combo)C++17
91 / 100
37 ms564 KiB
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = (a); i < (b); i++) using namespace std; #define pb push_back #include "combo.h" string guess_sequence(int N) { vector<char> btns = {'A', 'B', 'X', 'Y'}; char fst; for (char c : btns) { string p = ""; p += c; int coins = press(p); if (coins != 0) { fst = c; break; } } vector<char> oth; if (N == 1) { string res = ""; res += fst; return res; } for (char c : btns) { if (c != fst) oth.pb(c); } string ans = ""; ans += fst; rep(i, 1, N - 1) { string p = ""; p += ans; p += oth[0]; p += oth[0]; p += ans; p += oth[0]; p += oth[1]; p += ans; p += oth[0]; p += oth[2]; p += ans; p += oth[1]; int coins = press(p); if (coins == i) ans += oth[2]; else if (coins == i + 1) ans += oth[1]; else if (coins == i + 2) ans += oth[0]; else assert(false); } for (char c : oth) { string p = ans; p += c; int coins = press(p); if (coins == N) { return p; } } assert(false); return ""; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...