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