This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "combo.h"
#include <iostream>
std::string guess_sequence(int N) {
std::string head = "";
std::string str = "";
str = "AB";
char lead;
if (press(str)){
str = "A";
if (press(str)){
head = "A";
lead = 'A';
} else {
head = "B";
lead = 'B';
}
} else {
str = "X";
if (press(str)){
head = "X";
lead = 'X';
} else {
head = "Y";
lead = 'Y';
}
}
std::string a, b, c;
if (lead == 'A'){
a = "B";
b = "X";
c = "Y";
} else if (lead == 'B'){
a = "A";
b = "X";
c = "Y";
} else if (lead == 'X'){
a = "B";
b = "A";
c = "Y";
} else if (lead == 'Y'){
a = "B";
b = "X";
c = "A";
} else std::cout << "FATAL_ERROR1_";
for (int i = 1; i < N-1; i++){
/*str = "";
str += head;
str += a;
str += a;
str += head;
str += a;
str += b;
str += head;
str += a;
str += c;
str += head;
str += b;*/
str = head + a + a + head + a + b + head + a + c + head + b;
int coins = press(str);
if (coins == i+2) head += a;
else if (coins == i+1) head += b;
else if (coins == i) head += c;
else std::cout << "FATAL_ERROR2_";
}
/*str = "";
str += head;
str += a;
str += head;
str += b;*/
if (N == 1) return head;
str = head + a + head + b;
int coin = press(str);
if (coin == N-1){
head += c;
} else if (coin == N){
str = head + a;
coin = press(str);
if (coin == N-1) head += b;
else if (coin == N) head += a;
else std::cout << "FATAL_ERROR4_";
} else std::cout << "FATAL_ERROR3_";
return head;
}
/*
string p = "";
for (int i = 0; i < 4 * N; ++i) {
p += 'A';
}
int coins = press(p);
string S = "";
for (int i = 0; i < N; ++i) {
S += 'A';
}
return S;
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |