이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <stdio.h>
#include <iostream>
#include <string>
#include <assert.h>
using namespace std;
string C;
string guess_sequence(int N)
{
string S = "";
int a = press("AX");
if(a)
{
int x = press("A");
if(x) S = "A", C = "BXY";
else S = "X", C = "ABY";
}
else
{
int x = press("B");
if(x) S = "B", C = "AXY";
else S = "Y", C = "ABX";
}
if(N == S.size())
return S;
while(S.size() != N-1)
{
string T = S + C.substr(0,1);
for(int i = 0; i < 3; i++)
{
T += S + C.substr(1,1) + C.substr(i, 1);
}
int val = press(T);
if(val == S.size()+1)
S += C.substr(0,1);
else if(val == S.size()+2)
S += C.substr(1,1);
else
S += C.substr(2,1);
// cout << S << "\n";
if(S.size() == N-1)
break;
}
string T = S + C.substr(0,1) + S + C.substr(1,1);
int x = press(T);
if(x == N)
{
if(press(S + C.substr(0,1)) == N)
return S + C.substr(0,1);
else return S + C.substr(1,1);
}
else return S + C.substr(2,1);
return S;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:28:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | if(N == S.size())
| ~~^~~~~~~~~~~
combo.cpp:31:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
31 | while(S.size() != N-1)
| ~~~~~~~~~^~~~~~
combo.cpp:39:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | if(val == S.size()+1)
| ~~~~^~~~~~~~~~~~~
combo.cpp:41:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | else if(val == S.size()+2)
| ~~~~^~~~~~~~~~~~~
combo.cpp:47:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
47 | if(S.size() == N-1)
| ~~~~~~~~~^~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |