이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
string v = "ABXY";
void Guess_Next(string &s, int N) {
if(s.size() == N - 1) return;
// Will do this very ugly
if(s[0] == 'A') {
int answ = press(s + "B" + s + "XB" + s + "XY" + s + "XX");
if(answ == s.size() + 1) {
s += "B";
Guess_Next(s, N);
} else if(answ == s.size() + 2) {
s += "X";
Guess_Next(s, N);
} else if(answ == s.size()) {
s += "Y";
Guess_Next(s, N);
}
} else if(s[0] == 'B') {
int answ = press(s + "A" + s + "XA" + s + "XY" + s + "XX");
if(answ == s.size() + 1) {
s += "A";
Guess_Next(s, N);
} else if(answ == s.size() + 2) {
s += "X";
Guess_Next(s, N);
} else if(answ == s.size()) {
s += "Y";
Guess_Next(s, N);
}
} else if(s[0] == 'X') {
int answ = press(s + "A" + s + "BA" + s + "BY" + s + "BB");
if(answ == s.size() + 1) {
s += "A";
Guess_Next(s, N);
} else if(answ == s.size() + 2) {
s += "B";
Guess_Next(s, N);
} else if(answ == s.size()) {
s += "Y";
Guess_Next(s, N);
}
} else { // s[0] == 'Y'
int answ = press(s + "A" + s + "BA" + s + "BX" + s + "BB");
if(answ == s.size() + 1) {
s += "A";
Guess_Next(s, N);
} else if(answ == s.size() + 2) {
s += "B";
Guess_Next(s, N);
} else if(answ == s.size()) {
s += "X";
Guess_Next(s, N);
}
}
}
string guess_sequence(int N) {
string ans = "";
// Guessing the first character
if(press("AB") > 0) {
if(press("A") > 0)
ans = "A";
else ans = "B";
} else { // press("XY") > 0
if(press("X") > 0)
ans = "X";
else ans = "Y";
}
Guess_Next(ans, N);
for(int i = 0; i < v.size() - 1; i++) {
if(v[i] != ans[0] && press(ans + v[i]) == N) {
ans += v[i];
i = v.size();
}
}
if(ans.size() == N - 1)
ans += v.back();
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'void Guess_Next(std::string&, int)':
combo.cpp:8:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
8 | if(s.size() == N - 1) return;
| ~~~~~~~~~^~~~~~~~
combo.cpp:15:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | if(answ == s.size() + 1) {
| ~~~~~^~~~~~~~~~~~~~~
combo.cpp:18:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | } else if(answ == s.size() + 2) {
| ~~~~~^~~~~~~~~~~~~~~
combo.cpp:21:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | } else if(answ == s.size()) {
| ~~~~~^~~~~~~~~~~
combo.cpp:28:17: 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(answ == s.size() + 1) {
| ~~~~~^~~~~~~~~~~~~~~
combo.cpp:31:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | } else if(answ == s.size() + 2) {
| ~~~~~^~~~~~~~~~~~~~~
combo.cpp:34:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | } else if(answ == s.size()) {
| ~~~~~^~~~~~~~~~~
combo.cpp:41:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | if(answ == s.size() + 1) {
| ~~~~~^~~~~~~~~~~~~~~
combo.cpp:44:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | } else if(answ == s.size() + 2) {
| ~~~~~^~~~~~~~~~~~~~~
combo.cpp:47:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | } else if(answ == s.size()) {
| ~~~~~^~~~~~~~~~~
combo.cpp:54:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | if(answ == s.size() + 1) {
| ~~~~~^~~~~~~~~~~~~~~
combo.cpp:57:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | } else if(answ == s.size() + 2) {
| ~~~~~^~~~~~~~~~~~~~~
combo.cpp:60:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | } else if(answ == s.size()) {
| ~~~~~^~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:83:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
83 | for(int i = 0; i < v.size() - 1; i++) {
| ~~^~~~~~~~~~~~~~
combo.cpp:90:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
90 | if(ans.size() == N - 1)
| ~~~~~~~~~~~^~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |