이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <iostream>
using namespace std;
string fiAndLa(string pref) {
string A = "A";
string B = "B";
string C = "X";
string D = "Y";
string AA = A + A, AB = A + B, AC = A + C, AD = A + D,
BA = B + A, BB = B + B, BC = B + C, BD = B + D,
CA = C + A, CB = C + B, CC = C + C, CD = C + D,
DA = D + A, DB = D + B, DC = D + C, DD = D + D;
string res = "";
int coin = press(pref + A + pref + B);
if (coin > pref.size()) {
coin = press(pref + A);
if (coin == pref.size() + 1) {
res += A;
}
else {
res += B;
}
}
else {
coin = press(pref + C);
if (coin == pref.size() + 1) {
res += C;
}
else {
res += D;
}
}
return res;
}
std::string guess_sequence(int N) {
string A = "A";
string B = "B";
string C = "X";
string D = "Y";
string AA = A + A, AB = A + B, AC = A + C, AD = A + D,
BA = B + A, BB = B + B, BC = B + C, BD = B + D,
CA = C + A, CB = C + B, CC = C + C, CD = C + D,
DA = D + A, DB = D + B, DC = D + C, DD = D + D;
string res = "";
int coin;
if (N == 1) {
res += fiAndLa(res);
}
else if (N == 2) {
res += fiAndLa(res);
res += fiAndLa(res);
}
else {
res += fiAndLa(res);
string fi = res;
for (int i = 2; i <= N - 1; i++) {
if (fi == A) {
coin = press(res + BB + res + BC + res + BD + res + C);
if (coin == res.size() + 2) {
res += B;
}
else if (coin == res.size() + 1) {
res += C;
}
else res += D;
}
else if (fi == B) {
coin = press(res + AA + res + AC + res + AD + res + C);
if (coin == res.size() + 2) {
res += A;
}
else if (coin == res.size() + 1) {
res += C;
}
else res += D;
}
else if (fi == C) {
coin = press(res + BB + res + BC + res + BD + res + A);
if (coin == res.size() + 2) {
res += B;
}
else if (coin == res.size() + 1) {
res += A;
}
else res += D;
}
else {
coin = press(res + BB + res + BC + res + BD + res + C);
if (coin == res.size() + 2) {
res += B;
}
else if (coin == res.size() + 1) {
res += C;
}
else res += A;
}
}
res += fiAndLa(res);
}
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string fiAndLa(std::string)':
combo.cpp:15:14: 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 (coin > pref.size()) {
| ~~~~~^~~~~~~~~~~~~
combo.cpp:17:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | if (coin == pref.size() + 1) {
| ~~~~~^~~~~~~~~~~~~~~~~~
combo.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | if (coin == pref.size() + 1) {
| ~~~~~^~~~~~~~~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:59:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
59 | if (coin == res.size() + 2) {
| ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:62:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
62 | else if (coin == res.size() + 1) {
| ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:69:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | if (coin == res.size() + 2) {
| ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:72:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | else if (coin == res.size() + 1) {
| ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:79:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
79 | if (coin == res.size() + 2) {
| ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:82:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
82 | else if (coin == res.size() + 1) {
| ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:89:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
89 | if (coin == res.size() + 2) {
| ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:92:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
92 | else if (coin == res.size() + 1) {
| ~~~~~^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |