이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int n)
{
string ans;
char c[3];
int tmp = press("AB");
if (tmp == 2)
ans += "AB", c[0] = 'B', c[1] = 'X', c[2] = 'Y';
else if (tmp == 1)
if (press("A"))
ans += "A", c[0] = 'B', c[1] = 'X', c[2] = 'Y';
else
ans += "B", c[0] = 'A', c[1] = 'X', c[2] = 'Y';
else
if (press("X"))
ans += "X", c[0] = 'A', c[1] = 'B', c[2] = 'Y';
else
ans += "Y", c[0] = 'A', c[1] = 'B', c[2] = 'X';
if (ans.size() == n)
return ans;
while (ans.size() <= n - 2)
{
int tmp = press(ans + c[0] + c[1] + ans + c[0] + c[2] + ans + c[0] + c[0] + ans + c[1]);
if (tmp == ans.size() + 2)
ans += c[0];
else if (tmp == ans.size() + 1)
ans += c[1];
else
ans += c[2];
}
if (press(ans + c[0]) == n)
return ans + c[0];
else if (press(ans + c[1]) == n)
return ans + c[1];
else
return ans + c[2];
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
25 | if (ans.size() == n)
| ~~~~~~~~~~~^~~~
combo.cpp:27:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
27 | while (ans.size() <= n - 2)
| ~~~~~~~~~~~^~~~~~~~
combo.cpp:30:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | if (tmp == ans.size() + 2)
| ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:32:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | else if (tmp == ans.size() + 1)
| ~~~~^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |