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 <bits/stdc++.h>
using namespace std;
string guess_sequence(int N) {
char firstLetter='X';
if(press("XY")){
if(press("X")) firstLetter = 'X';
else firstLetter = 'Y';
}else{
if(press("A")) firstLetter = 'A';
else firstLetter = 'B';
}
string wyn = "";
wyn.push_back(firstLetter);
for(int i = 1; i < N-1; i++){
if(firstLetter=='A'){
int tmp = press(wyn+"X"+wyn+"YX"+wyn+"YB"+wyn+"YY");
if(tmp==(int)wyn.size()){
wyn.push_back('B');
}else if(tmp==(int)wyn.size()+1){
wyn.push_back('X');
}else wyn.push_back('Y');
}
if(firstLetter=='B'){
int tmp = press(wyn+"X"+wyn+"YX"+wyn+"YA"+wyn+"YY");
if(tmp==(int)wyn.size()){
wyn.push_back('A');
}else if(tmp==(int)wyn.size()+1){
wyn.push_back('X');
}else wyn.push_back('Y');
}
if(firstLetter=='X'){
int tmp = press(wyn+"B"+wyn+"YB"+wyn+"YA"+wyn+"YY");
if(tmp==(int)wyn.size()){
wyn.push_back('A');
}else if(tmp==(int)wyn.size()+1){
wyn.push_back('B');
}else wyn.push_back('Y');
}
if(firstLetter=='Y'){
int tmp = press(wyn+"B"+wyn+"XB"+wyn+"XA"+wyn+"XX");
if(tmp==(int)wyn.size()){
wyn.push_back('A');
}else if(tmp==(int)wyn.size()+1){
wyn.push_back('B');
}else wyn.push_back('X');
}
}
if(N>1){
char lastLetter;
if(firstLetter=='A'){
int tmp = press(wyn+"X"+wyn+"Y");
if(tmp==N){
tmp = press(wyn+"X");
if(tmp==N){
lastLetter = 'X';
}else lastLetter = 'Y';
}else{
lastLetter='B';
}
}
if(firstLetter=='B'){
int tmp = press(wyn+"X"+wyn+"Y");
if(tmp==N){
tmp = press(wyn+"X");
if(tmp==N){
lastLetter = 'X';
}else lastLetter = 'Y';
}else{
lastLetter='A';
}
}
if(firstLetter=='X'){
int tmp = press(wyn+"A"+wyn+"Y");
if(tmp==N){
tmp = press(wyn+"A");
if(tmp==N){
lastLetter = 'A';
}else lastLetter = 'Y';
}else{
lastLetter='B';
}
}
if(firstLetter=='Y'){
int tmp = press(wyn+"A"+wyn+"X");
if(tmp==N){
tmp = press(wyn+"A");
if(tmp==N){
lastLetter = 'A';
}else lastLetter = 'X';
}else{
lastLetter='B';
}
}
wyn.push_back(lastLetter);
}
return wyn;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |