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<iostream>
#include "combo.h"
using namespace std;
int press2(string s,int n)
{
//cout<<s.size()<<' '<<4*n<<'\n';
if(s.size()>4*n)
while(1){}
return press(s);
}
string guess_sequence(int n)
{
int r,poz=0,cnt=-1;
string a[3],cand[4]={"A","B","X","Y"};
string q,rez;
q="AB";
r=press2(q,n);
if(r)
poz=0;
else
poz=2;
q=cand[poz];
r=press2(q,n);
if(r==0)
poz++;
for(int i=0;i<4;i++)
if(i!=poz)
{
cnt++;
a[cnt]=cand[i];
}
rez=cand[poz];
cnt=1;
poz=2;
for(int i=2;i<n;i++)
{
q=rez+a[0]+rez+a[1]+a[0]+rez+a[1]+a[1]+rez+a[1]+a[2];
r=press2(q,n);
if(r==i-1)
{
rez=rez+a[2];
continue;
}
else
if(r==i)
{
rez=rez+a[0];
continue;
}
else
rez=rez+a[1];
}
q=rez+a[0]+rez+a[1];
r=press2(q,n);
if(r==n)
{
q=rez+a[0];
r=press2(q,n);
if(r==n)
rez=rez+a[0];
else
rez=rez+a[1];
}
else
rez=rez+a[2];
return rez;
}
Compilation message (stderr)
combo.cpp: In function 'int press2(std::string, int)':
combo.cpp:7:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
7 | if(s.size()>4*n)
| ~~~~~~~~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |