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"
std::string guess_sequence(int N) {
std::string p = "";
std::string p2= "";
std::string ans= "";
int ban;
char c[4];
c[0]='A';
c[1]='B';
c[2]='X';
c[3]='Y';
p += c[0];
p += c[1];
int coins = press(p);
if(coins>=1)
{
p.clear();
p+=c[0];
coins = press(p);
if(coins==1)
{
ans+=c[0];
ban=0;
}
else
{
ans+=c[1];
ban=1;
}
}
else
{
p.clear();
p+=c[2];
coins = press(p);
if(coins==1)
{
ans+=c[2];
ban=2;
}
else
{
ans+=c[3];
ban=3;
}
}
// 2 steps
int pos;
int pos2;
int pos3;
pos=0;
if(pos==ban)
{
pos++;
}
pos2=pos+1;
if(pos2==ban)
{
pos2++;
}
pos3=pos2+1;
if(pos3==ban)
{
pos3++;
}
for(int i=1;i<N-1;i++)
{
p2.clear();
for(int j=0;j<4;j++)
{
if(j!=ban)
{
p2+=ans;
p2+=c[pos];
p2+=c[j];
}
}
p2+=ans;
p2+=c[pos2];
coins = press(p2);
if(coins==i)
{
ans+=c[pos3];
}
else if(coins==i+1)
{
ans+=c[pos2];
}
else
{
ans+=c[pos];
}
}
// n-2 steps
if(N==1)
{
return ans;
}
else
{
p2.clear();
p2+=ans;
p2+=c[pos];
coins = press(p2);
if(coins==N)
{
std::string S = "";
S+=ans;
S+=c[pos];
return S;
}
p2.clear();
p2+=ans;
p2+=c[pos2];
coins = press(p2);
if(coins==N)
{
std::string S = "";
S+=ans;
S+=c[pos2];
return S;
}
std::string S = "";
S+=ans;
S+=c[pos3];
return S;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |