이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
vector<char> chars {'A','B','X','Y'};
std::string guess_sequence(int N) {
srand(time(NULL));
string ans = "";
//find first character, 2 guess
char firstChar;
if (press(ans+chars[0]+chars[1]) > 0) {
if (press(ans+chars[0]) > 0) {
firstChar = chars[0];
}
else firstChar = chars[1];
}
else {
if (press(ans+chars[2]) > 0) {
firstChar = chars[2];
}
else firstChar = chars[3];
}
chars.erase(remove(chars.begin(),chars.end(),firstChar),chars.end());
ans += firstChar;
//each character, 1 guess
while (4*ans.size()+7 <= 4*N) { //while strategy works
int z = press(ans+chars[0]+ans+chars[1]+chars[0]+ans+chars[1]+chars[1]+ans+chars[1]+chars[2]) - ans.size();
// cout << "guess: " << (ans+chars[0]+ans+chars[1]+chars[0]+ans+chars[1]+chars[1]+ans+chars[1]+chars[2]) << " " << z;
if (z == 2) {
ans += chars[1];
}
else if (z == 1) {
ans += chars[0];
}
else {
ans += chars[2];
}
// cout << ",new: " << ans << "\n";
}
while (ans.size() < N) {
if (press(ans+chars[0])-ans.size() > 0) {
ans += chars[0];
}
else if (press(ans+chars[1])-ans.size() > 0) ans += chars[1];
else ans += chars[2];
}
// cout << ans << "\n";
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:37:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
37 | while (4*ans.size()+7 <= 4*N) { //while strategy works
| ~~~~~~~~~~~~~~~^~~~~~
combo.cpp:58:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
58 | while (ans.size() < N) {
| ~~~~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |