이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <combo.h>
std::string guess_sequence(int N)
{
using namespace std;
int n = N;
string str = "";
char first;
{
int x, y;
x = press("AB");
y = press("BX");
if(x == 0 && y == 0){
first = 'Y';
}
if(x == 1 && y == 0){
first = 'A';
}
if(x == 0 && y == 1){
first = 'X';
}
if(x == 1 && y == 1){
first = 'B';
}
}
str += first;
if(first == 'Y'){
for(int i = 0; i < n - 2; ++i){
int delta = str.size();
int x = press(str + "A" + str + "BA" + str + "BB" + str + "BX");
if(x - delta == 0){
str += "X";
}
if(x - delta == 1){
str += "A";
}
if(x - delta == 2){
str += "B";
}
}
int delta = str.size();
int x = press(str + "A");
int y = press(str + "B");
if(x - delta == 0 && y - delta == 0){
str += "X";
}
if(x - delta == 1){
str += "A";
}
if(y - delta == 1){
str += "B";
}
}
if(first == 'A'){
for(int i = 0; i < n - 2; ++i){
int delta = str.size();
int x = press(str + "Y" + str + "BY" + str + "BB" + str + "BX");
if(x - delta == 0){
str += "X";
}
if(x - delta == 1){
str += "Y";
}
if(x - delta == 2){
str += "B";
}
}
int delta = str.size();
int x = press(str + "X");
int y = press(str + "Y");
if(x - delta == 0 && y - delta == 0){
str += "B";
}
if(x - delta == 1){
str += "X";
}
if(y - delta == 1){
str += "Y";
}
}
if(first == 'X'){
for(int i = 0; i < n - 2; ++i){
int delta = str.size();
int x = press(str + "A" + str + "BA" + str + "BB" + str + "BY");
if(x - delta == 0){
str += "Y";
}
if(x - delta == 1){
str += "A";
}
if(x - delta == 2){
str += "B";
}
}
int delta = str.size();
int x = press(str + "A");
int y = press(str + "B");
if(x - delta == 0 && y - delta == 0){
str += "Y";
}
if(x - delta == 1){
str += "A";
}
if(y - delta == 1){
str += "B";
}
}
if(first == 'B'){
for(int i = 0; i < n - 2; ++i){
int delta = str.size();
int x = press(str + "A" + str + "XA" + str + "XX" + str + "XY");
if(x - delta == 0){
str += "Y";
}
if(x - delta == 1){
str += "A";
}
if(x - delta == 2){
str += "X";
}
}
int delta = str.size();
int x = press(str + "X");
int y = press(str + "Y");
if(x - delta == 0 && y - delta == 0){
str += "A";
}
if(x - delta == 1){
str += "X";
}
if(y - delta == 1){
str += "Y";
}
}
return str;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |