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>
using namespace std;
using ll = long long;
template<class T> bool cmin(T &i, T j) { return i > j ? i=j,true:false; }
template<class T> bool cmax(T &i, T j) { return i < j ? i=j,true:false; }
int press(string p);
string guess_sequence(int n) {
string res = "";
vector<string> v = {"A","B","X","Y"};
for (int i=0;i<=2;i++) {
if (press(v[i])) {
res = v[i];
break;
}
}
if (res == "") {
res = "Y";
}
v.erase(find(v.begin(),v.end(),res));
for (int i=2;i<n;i++) {
int r = press(res+v[0]+res+v[1]+v[0]+res+v[1]+v[1]+res+v[1]+v[2]);
if (r == i-1) {
res += v[2];
} else if (r == i) {
res += v[0];
} else {
assert(r == i+1);
res += v[1];
}
assert((int)res.size() == i);
}
/*
if((int)res.size() != n-1) {
while(true) {}
}
*/
// gotta guess the last one
if (press(res+v[0]) == n) {
res += v[0];
} else if (press(res+v[1]) == n) {
res += v[1];
} else {
res += v[2];
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |