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;
#define pb push_back
int press(string p);
string guess_sequence(int n)
{
string res = "";
string temp = "ABXY";
for(int i = 0; i<3; i++)
{
string tr = "";
tr.pb(temp[i]);
if(press(tr)==1)
{
res.pb(temp[i]);
break;
}
}
if(res.length()==0)
res.pb('Y');
string used = "";
for(int i = 0; i<4; i++)
{
if(res[0]==temp[i])
continue;
used.pb(temp[i]);
}
for(int i = 2; i<=n; i++)
{
string s = "";
s = s + res[0] + used[0];
s = s + res[0] + used[1] + used[0];
s = s + res[0] + used[1] + used[1];
s = s + res[0] + used[1] + used[2];
int k = press(s);
if(k==(int)res.size())
res.pb(used[2]);
else if(k==(int)res.size() + 1)
res.pb(used[0]);
else
res.pb(used[1]);
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |