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"
using namespace std;
const int maxn = 2005;
const char buttons[] = {'A', 'B', 'X', 'Y'};
//int press(string s) {
// cout << "? " << s << endl;
// int x; cin >> x;
// return x;
//}
string guess_sequence(int n) {
string ans;
string s;
char ft = 'A';
for(int i = 0; i < 4; ++i) {
if(i == 3) {
ft = buttons[i];
break;
}
s = "";
s += buttons[i];
int x = press(s);
if(x) {
ft = buttons[i];
break;
}
}
string other;
for(int i = 0; i < 4; ++i) {
if(buttons[i] != ft) {
other += buttons[i];
}
}
ans += ft;
for(int len = 2; len <= n; len++) {
s = ans + other[0];
for(int j = 0; j < 4; ++j) {
if(buttons[j] == ft) continue;
s = s + ans + other[1] + buttons[j];
}
int x = press(s) - (int)ans.size();
if(!x) ans += other[2];
else if(x == 1) ans += other[0];
else ans += other[1];
}
return ans;
}
//void solve() {
// int n; cin >> n;
// cout << guess_sequence(n);
//}
//signed main() {
// ios_base::sync_with_stdio(0);
// cin.tie(0);
//
// solve();
// return 0;
//}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |