이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "combo.h"
using namespace std;
#define fto(i,a,b) for(int i = a; i <= b; ++i)
// int press(string s) {
// cout << s << endl;
// fflush(stdout);
// int gt; cin >> gt;
// return gt;
// }
string check;
string build(string s) {
string ans = s+check[0];
int l = check.length();
fto (i, 0, (int)l-1) ans = ans + s+check[1]+check[i];
return ans;
}
string last(string s) {
if (press(s+check[0]+s+check[1]) == s.length()) {
return s+check[2];
} else {
if (press(s+check[1]) == s.length()) return s+check[0];
return s+check[1];
}
return "0.0";
}
char fir() {
int tmp = press("AB");
if (tmp == 0) {
tmp = press("X");
if (tmp == 1) return 'X';
return 'Y';
} else {
tmp = press("A");
if (tmp == 1) return 'A';
return 'B';
}
return '.';
}
string guess_sequence(int n) {
string s;
check = "ABXY";
char gt = fir(); s = gt;
fto (i, 0, (int)check.length()-1) {
if (gt == check[i]) {
check.erase(check.begin()+i);
break;
}
}
fto (i, 2, n-1) {
int tmp = press(build(s));
if (tmp == s.length()) s = s + check[2];
else if (tmp == s.length()+1) s = s + check[0];
else if (tmp == s.length()+2) s = s + check[1];
}
if (n != 1) s = last(s);
return s;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string last(std::string)':
combo.cpp:23:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | if (press(s+check[0]+s+check[1]) == s.length()) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:26:25: 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 (press(s+check[1]) == s.length()) return s+check[0];
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:58:11: 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 (tmp == s.length()) s = s + check[2];
| ~~~~^~~~~~~~~~~~~
combo.cpp:59:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
59 | else if (tmp == s.length()+1) s = s + check[0];
| ~~~~^~~~~~~~~~~~~~~
combo.cpp:60:16: 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 (tmp == s.length()+2) s = s + check[1];
| ~~~~^~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |