이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
char chr[3];
map<string, int> mp;
int ask(string str){
if(mp.find(str) == mp.end()) mp[str] = press(str);
return mp[str];
}
string guess_sequence(int n){
string s;
if(ask("AB")){
if(ask("A")){
s = "A";
chr[0] = 'B', chr[1] = 'X', chr[2] = 'Y';
}
else{
s = "B";
chr[0] = 'A', chr[1] = 'X', chr[2] = 'Y';
}
}
else{
if(ask("X")){
s = "X";
chr[0] = 'A', chr[1] = 'B', chr[2] = 'Y';
}
else{
s = "Y";
chr[0] = 'A', chr[1] = 'B', chr[2] = 'X';
}
}
while(s.size() < n){
if(n - s.size() >= 3){
string nextstr = s + chr[0] + chr[0] + chr[0] + s + chr[0] + chr[1] + chr[0] + s + chr[0] + chr[2] + chr[0] + s + chr[1] + chr[0] + chr[0];
if(ask(nextstr) - s.size() == 0) s += chr[2];
else if(ask(nextstr) - s.size() == 1){
if(ask(s + chr[1] + chr[1]) - s.size() >= 2) s += string{chr[1]} + chr[1];
else s += string{chr[1]} + chr[2];
}
else if(ask(nextstr) - s.size() == 2){
if(ask(s + chr[0] + chr[0] + chr[1] + s + chr[0] + chr[1] + chr[1]) - s.size() == 0){
if(ask(s + chr[1] + chr[0] + chr[1]) - s.size() >= 3) s += string{chr[1]} + chr[0] + chr[1];
else s += string{chr[1]} + chr[0] + chr[2];
}
else if(ask(s + chr[0] + chr[0] + chr[1] + s + chr[0] + chr[1] + chr[1]) - s.size() == 1){
if(ask(s + chr[0] + chr[2] + chr[1]) - s.size() >= 3) s += string{chr[0]} + chr[2] + chr[1];
else s += string{chr[0]} + chr[2] + chr[2];
}
else if(ask(s + chr[0] + chr[0] + chr[1] + s + chr[0] + chr[1] + chr[1]) - s.size() == 2){
if(ask(s + chr[0] + chr[0] + chr[2]) - s.size() >= 3) s += string{chr[0]} + chr[0] + chr[2];
else s += string{chr[0]} + chr[1] + chr[2];
}
else{
if(ask(s + chr[0] + chr[0] + chr[1]) - s.size() >= 3) s += string{chr[0]} + chr[0] + chr[1];
else s += string{chr[0]} + chr[1] + chr[1];
}
}
else{
if(ask(s + chr[0] + chr[0] + chr[0] + s + chr[0] + chr[1] + chr[0]) - s.size() >= 3){
if(ask(s + chr[0] + chr[0] + chr[0]) - s.size() >= 3) s += string{chr[0]} + chr[0] + chr[0];
else s += string{chr[0]} + chr[1] + chr[0];
}
else{
if(ask(s + chr[0] + chr[2] + chr[0]) - s.size() >= 3) s += string{chr[0]} + chr[2] + chr[0];
else s += string{chr[1]} + chr[0] + chr[0];
}
}
}
else if(n - s.size() == 2){
string nextstr = s + chr[0] + chr[0] + s + chr[0] + chr[1] + s + chr[1] + chr[0] + s + chr[1] + chr[1];
if(ask(nextstr) - s.size() == 0) s += chr[2];
else if(ask(nextstr) - s.size() == 1){
if(ask(s + chr[0] + chr[2]) - s.size() == 2) s += string{chr[0]} + chr[2];
else s += string{chr[1]} + chr[2];
}
else{
if(ask(s + chr[0] + chr[0] + s + chr[0] + chr[1]) - s.size() == 2){
if(ask(s + chr[0] + chr[0]) - s.size() == 2) s += string{chr[0]} + chr[0];
else s += string{chr[0]} + chr[1];
}
else{
if(ask(s + chr[1] + chr[0]) - s.size() == 2) s += string{chr[1]} + chr[0];
else s += string{chr[1]} + chr[1];
}
}
}
else if(n - s.size() == 1){
if(ask(s + chr[0]) - s.size() == 1) s += chr[0];
else if(ask(s + chr[1]) - s.size() == 1) s += chr[1];
else s += chr[2];
}
}
return s;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:44:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
44 | while(s.size() < n){
| ~~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |