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>
#include <fstream>
#include <cstring>
using namespace std;
std::string guess_sequence(int N) {
std::string p = "";
if(0 < press("AB"))
if(press("A"))
p = "A";
else
p = "B";
else
if(press("Y"))
p = "Y";
else
p = "X";
string init = p;
for(int i = 2 ; i < N ; i++){
if(init == "A") {
string que = p + "X" + p + "YX" + p + "YY" + p + "YB";
int coins = press(que);
if(coins == i - 1)
p += "B";
else if(coins == i)
p += "X";
else
p += "Y";
} else if(init == "B"){
string que = p + "X" + p + "YX" + p + "YY" + p + "YA";
int coins = press(que);
if(coins == i - 1)
p += "A";
else if(coins == i)
p += "X";
else
p += "Y";
} else if(init == "X"){
string que = p + "B" + p + "YB" + p + "YY" + p + "YA";
int coins = press(que);
if(coins == i - 1)
p += "A";
else if(coins == i)
p += "B";
else
p += "Y";
} else {
string que = p + "X" + p + "AX" + p + "AA" + p + "AB";
int coins = press(que);
if(coins == i - 1)
p += "B";
else if(coins == i)
p += "X";
else
p += "A";
}
}
if(1 < N){
if(press(p + "X" + p + "Y") == N)
if(press(p + "X") == N)
p += "X";
else
p += "Y";
else
if(press(p + "A") == N)
p += "A";
else
p += "B";
}
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |