이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
char buttons[] = {'A' , 'B' , 'X' , 'Y'};
int N;
string S;
string remain;
/*int press(string p)
{
printf("-> %s\n",p.c_str());
int a;
scanf("%d",&a);
return a;
}*/
void getFirstLetter()
{
if( press("AB") >= 1 )
{
if(press("A") == 1) S = "A";
else S = "B";
}
else
{
if(press("X") == 1) S = "X";
else S = "Y";
}
}
string guess_sequence(int n)
{
N = n;
getFirstLetter();
if(N == 1) return S;
for(int g = 0 ; g < 4 ; g++)
if(buttons[g] != S[0])
remain.push_back( buttons[g] );
for(int g = 1 ; g < N - 1 ; g++)
{
string cur;
for(int h = 0 ; h < 3 ; h++)
cur = cur + S + remain[0] + remain[h];
cur = cur + S + remain[1];
int aux = press( cur );
if(aux == S.size()) S = S + remain[2];
if(aux == S.size() + 1) S = S + remain[1];
if(aux >= S.size() + 2) S = S + remain[0];
}
if(press(S + remain[0]) == N) return S + remain[0];
if(press(S + remain[1]) == N) return S + remain[1];
return S + remain[2];
}
/*int main()
{
int nn;
scanf("%d",&nn);
printf("%s\n",guess_sequence(nn).c_str());
}*/
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:60:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | if(aux == S.size()) S = S + remain[2];
| ~~~~^~~~~~~~~~~
combo.cpp:61:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | if(aux == S.size() + 1) S = S + remain[1];
| ~~~~^~~~~~~~~~~~~~~
combo.cpp:62:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
62 | if(aux >= S.size() + 2) S = S + remain[0];
| ~~~~^~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |