이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |