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 + used[0];
s = s + res + used[1] + used[0];
s = s + res + used[1] + used[1];
s = s + res + used[1] + used[2];
int k = press(s);
if(k==(int)res.length())
res.pb(used[2]);
if(k==(int)res.length() + 1)
res.pb(used[0]);
if(k==(int)res.length()+2)
res.pb(used[1]);
}
if((int)res.length()!=n)
{
string t = res + used[0];
if(press(t)==n)
{
res = res + used[0];
return res;
}
t = res + used[1];
if(press(t)==n)
{
res = res + used[1];
return res;
}
res = res + used[2];
return res;
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |