제출 #1105829

#제출 시각아이디문제언어결과실행 시간메모리
1105829magician콤보 (IOI18_combo)C++14
100 / 100
30 ms1840 KiB
#include <bits/stdc++.h> #include "combo.h" #define MASK(i) (1ll << (i)) #define BIT(x, i) (((x) >> (i)) & 1) #define REP(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i) #define REPD(i, a, b) for(int i = (a), _b = (b); i >= _b; --i) #define ALL(v) (v).begin(), (v).end() #define SZ(v) (int)(v).size() #define PATHWA "A" #define fi first #define se second #define ll long long using namespace std; /* int press(string p) { const string S = "A"; int res = 0; REP(l, 1, SZ(S)) { REP(i, 0, SZ(p) - l) { if(S.substr(0, l) == p.substr(i, l)) { res = l; break; } } } cout << "? " << p << '\n'; cout << res << '\n'; return res; } //*/ const vector<char> a = {'A', 'B', 'X', 'Y'}; vector<char> b; int guess_one(const string& s) { int len = press(s + a[0] + s + a[1]); int idx = 2 * (len < SZ(s) + 1); len = press(s + a[idx]); idx += (len < SZ(s) + 1); return idx; } int guess_two(const string& s) { int len = press(s + b[0] + b[0] + s + b[0] + b[1] + s + b[0] + b[2] + s + b[1]); if(len == SZ(s) + 2) { return 0; } if(len == SZ(s) + 1) { return 1; } return 2; } string guess_sequence(int N) { string res; res.push_back(a[guess_one(res)]); b.clear(); REP(i, 0, 3) { if(res[0] != a[i]) { b.push_back(a[i]); } } REP(len, 2, N - 1) { res.push_back(b[guess_two(res)]); } if(SZ(res) < N) { res.push_back(a[guess_one(res)]); } return res; } /* int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(PATHWA".INP", "r")) { freopen(PATHWA".INP", "r", stdin); freopen(PATHWA".OUT", "w", stdout); } cout << guess_sequence(1); return 0; } //*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...