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) {
srand(time(nullptr));
string res = "";
vector<string> v = {"A","B","X","Y"};
string F;
for (auto &x: v) {
if (press(x) == 1) {
F = x;
break;
}
}
res += F;
for (int i=2;i<=n;i++) {
vector<bool> tried(4);
while(true) {
int x;
do {
x = rand() % 4;
} while(tried[x] || v[x] == F);
tried[x] = true;
if (press(res+v[x]) == i) {
res += v[x];
break;
}
}
}
return res;
}
/*
string W = "ABXYY";
int sz = 5;
int press(string p) {
for (int i=1;i<=sz;i++) {
if (p.find(W.substr(0,i)) == string::npos) {
return i-1;
}
}
return sz;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout << guess_sequence(sz) << endl;
}
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |