이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
using namespace std;
std::string litere;
char FindFirstLetter () {
int val = press("AB");
if (val >= 1) {
val = press("A");
if (val == 1) return 'A';
else return 'B';
}
val = press("X");
if (val == 1) return 'X';
else return 'Y';
}
int PrimaIntrebare (std::string ans, std::string posibil) {
std::string p;
p = ans + posibil[0] + posibil[2];
p = p + ans + posibil[1] + posibil[2];
p = p + ans + posibil[0] + posibil[0];
return press(p);
}
int ADouaIntrebare (std::string ans, std::string posibil) {
std::string p;
p = ans + posibil[0] + posibil[2];
return press(p);
}
int ATreiaIntrebare (std::string ans, std::string posibil) {
std::string p;
p = ans + posibil[1] + posibil[0];
return press(p);
}
void Special_Case (std::string &ans, std::string posibil) {
std::string p;
p = ans + posibil[0] + ans + posibil[1];
int val = press(p);
if (val == ans.size()) {
ans = ans + posibil[2];
return;
}
p = ans + posibil[0];
val = press(p);
if (val == ans.size()) {
ans = ans + posibil[1];
return;
}
ans = ans + posibil[0];
}
std::string guess_sequence(int N) {
char ch = FindFirstLetter();
std::string ans;
ans.push_back(ch);
litere = "ABXY";
std::string unused_litere;
for (int i = 0; i < 4; ++ i )
if (ch != litere[i]) unused_litere.push_back(litere[i]);
for (int i = 2; i <= N; i += 2) {
if (i == N) {
Special_Case(ans, unused_litere);
break;
}
int val = PrimaIntrebare(ans, unused_litere);
if (val == ans.size()) {
ans.push_back(unused_litere[2]);
i --;
}
else if (val == ans.size() + 2) {
val = ADouaIntrebare(ans, unused_litere);
if (val == ans.size()) {
ans.push_back(unused_litere[1]);
ans.push_back(unused_litere[2]);
}
else if (val == ans.size() + 1) {
ans.push_back(unused_litere[0]);
ans.push_back(unused_litere[0]);
}
else {
ans.push_back(unused_litere[0]);
ans.push_back(unused_litere[2]);
}
}
else {
val = ATreiaIntrebare(ans, unused_litere);
if (val == ans.size()) {
ans.push_back(unused_litere[0]);
ans.push_back(unused_litere[1]);
}
else if (val == ans.size() + 1) {
ans.push_back(unused_litere[1]);
ans.push_back(unused_litere[1]);
}
else {
ans.push_back(unused_litere[1]);
ans.push_back(unused_litere[0]);
}
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'void Special_Case(std::string&, std::string)':
combo.cpp:50:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | if (val == ans.size()) {
| ~~~~^~~~~~~~~~~~~
combo.cpp:58:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | if (val == ans.size()) {
| ~~~~^~~~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:85:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
85 | if (val == ans.size()) {
| ~~~~^~~~~~~~~~~~~
combo.cpp:89:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
89 | else if (val == ans.size() + 2) {
| ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:92:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
92 | if (val == ans.size()) {
| ~~~~^~~~~~~~~~~~~
combo.cpp:96:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
96 | else if (val == ans.size() + 1) {
| ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:108:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
108 | if (val == ans.size()) {
| ~~~~^~~~~~~~~~~~~
combo.cpp:112:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
112 | else if (val == ans.size() + 1) {
| ~~~~^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |