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 "combo.h"
#include <bits/stdc++.h>
using namespace std;
vector<char> tab{'A','B','X','Y'};
string guess_sequence(int N) {
string p = "AB";
string ph="";
if(press(p)>=1){
p="A";
if(press(p)==1)ph="A";
else ph="B";
}
else{
p="X";
if(press(p)==1)ph="X";
else ph="Y";
}
if(N==1)return ph;
for (int i = 0; i < 4; ++i)
if(tab[i]==ph[0]){tab.erase(tab.begin()+i);break;}
for (int i = 1; i < N-1; ++i)
{
p=ph+tab[0];
for(auto car:tab)
p+=ph+tab[1]+car;
int coins=press(p);
//cerr<<p<<" "<<coins<<"\n";
if(coins==(int)(ph.size()))ph+=tab[2];
else if(coins==(int)(ph.size()+1))ph+=tab[0];
else ph+=tab[1];
//cerr<<ph<<"\n";
}
if(press(ph+tab[0])==N)ph+=tab[0];
else if(press(ph+tab[1])==N)ph+=tab[1];
else ph+=tab[2];
return ph;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |