This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 = "ABXYY";
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)]);
}
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(5);
return 0;
}
//*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |