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;
int press(string s);
void firstorlast(string &res,char buttons[], char temp[],char narrow[])
{
if(press(res+buttons[0]+res+buttons[1])>res.size())
{
temp[0]=buttons[0],temp[1]=buttons[1];
}
else
{
temp[0]=buttons[2],temp[1]=buttons[3];
}
if(press(res+temp[0])>res.size())
{
res+=temp[0];
}
else
{
res+=temp[1];
}
for(int i=0,j=0;i<4;i++)
{
if(buttons[i]!=res.back())
{
narrow[j]=buttons[i];
j++;
}
}
}
string guess_sequence(int N)
{
string res="";
char buttons[4]={'A','B','X','Y'},temp[2]={},narrow[3]={};
firstorlast(res, buttons, temp, narrow);
if(N==1)
{
return res;
}
while(res.size()<N-1)
{
int tmp=press(res+narrow[0]+narrow[0]+res+narrow[0]+narrow[1]+res+narrow[0]+narrow[2]+res+narrow[1]);
if(tmp==res.size())
{
res+=narrow[2];
}
else if(tmp==res.size()+1)
{
res+=narrow[1];
}
else
{
res+=narrow[0];
}
}
firstorlast(res, buttons, temp, narrow);
return res;
}
Compilation message (stderr)
combo.cpp: In function 'void firstorlast(std::string&, char*, char*, char*)':
combo.cpp:9:44: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
9 | if(press(res+buttons[0]+res+buttons[1])>res.size())
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:17:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | if(press(res+temp[0])>res.size())
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:44:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
44 | while(res.size()<N-1)
| ~~~~~~~~~~^~~~
combo.cpp:47:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | if(tmp==res.size())
| ~~~^~~~~~~~~~~~
combo.cpp:51:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
51 | else if(tmp==res.size()+1)
| ~~~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |