제출 #603650

#제출 시각아이디문제언어결과실행 시간메모리
603650yuto1115콤보 (IOI18_combo)C++17
100 / 100
32 ms696 KiB
#include "combo.h" #include "bits/stdc++.h" #define rep(i, n) for(ll i = 0; i < ll(n); ++i) #define rep2(i, s, n) for(ll i = ll(s); i < ll(n); ++i) #define rrep(i, n) for(ll i = ll(n)-1; i >= 0; --i) #define pb push_back #define eb emplace_back #define all(a) a.begin(),a.end() #define SZ(a) int(a.size()) using namespace std; using ll = long long; using P = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vb = vector<bool>; using vvb = vector<vb>; using vp = vector<P>; using vvp = vector<vp>; using vs = vector<string>; string guess_sequence(int n) { const string S = "ABXY"; string res; string rem; { int a = press("XY") > 0; int b = press(S.substr(a * 2 + 1, 1)) > 0; res.pb(S[a * 2 + b]); rep(i, 4) if (i != a * 2 + b) rem.pb(S[i]); } auto f = [&](int i, int j) -> string { string t = res; t.pb(rem[i]); t.pb(rem[j]); return t; }; while (SZ(res) < n) { if (SZ(res) < n - 1) { int now = press(f(0, 0) + f(0, 1) + f(1, 0)); if (now == SZ(res) + 2) { now = press(f(0, 0)); if (now == SZ(res) + 2) res = f(0, 0); else if (now == SZ(res) + 1) res = f(0, 1); else res = f(1, 0); } else if (now == SZ(res) + 1) { now = press(f(1, 1)); if (now == SZ(res) + 2) res = f(1, 1); else if (now == SZ(res) + 1) res = f(1, 2); else res = f(0, 2); } else { assert(now == SZ(res)); res.pb(rem[2]); } } else { string t = res; t.pb(rem[0]); if (press(t) == n) { res.pb(rem[0]); } else { t.pop_back(); t.pb(rem[1]); res.pb(press(t) == n ? rem[1] : rem[2]); } } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...