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 <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include "combo.h"
using namespace std;
string guess_sequence(int N) {
string p="";
string S="";
int guardado,coins;
bool A,B,X,Y;
p += 'A';
for (int i = 1; i < N; ++i) {
p += 'B';
}
coins = press(p);
if(coins==0){//Empieza x X o Y
p += 'X';
for (int i = 1; i < N; ++i) {
p += 'A';
}
coins=press(p);
if (coins==0){//Empieza x Y
S+='Y';
Y=false;
}
else if (coins==1){//Empieza x X y no sigue A
S+='X';
A=false;
}
else {
for(int c=0;c<coins;c++){//Empieza x X y sigue A
S+=p[c];
}
A=false;
}
}
else if(coins==1){//Empieza x A o x B
p+='B';
for (int i = 1; i < N; ++i) {
p += 'X';
}
coins=press(p);
if(coins==0){//Empieza x A y no sigue B
S+='A';
B=false;
}
else if (coins==1){//Empieza x B y no sigue X
S+='B';
X=false;
}
else {
for(int c=0;c<coins;c++){//Empieza x B y sigue X
S+=p[c];
}
X=false;
}
}
else {//Empieza x A y sigue B
for(int c=0;c<coins;c++){
S+=p[c];
}
B=false;
}
guardado=coins;
while(coins<N){
p="";
if (S[0]=='A'){
for (int i = 0; i < N-coins; ++i) {
if (B) p += 'B';
else if (X) p += 'X';
else if (Y) p += 'Y';
}
}
else if (S[0]=='B'){
for (int i = 0; i < N-coins; ++i) {
if (A) p += 'A';
else if (X) p += 'X';
else if (Y) p += 'Y';
}
}
else if (S[0]=='X'){
for (int i = 0; i < N-coins; ++i) {
if (A)p += 'A';
else if (B) p += 'B';
else if (Y) p += 'Y';
}
}
else if (S[0]=='Y'){
for (int i = 0; i < N-coins; ++i) {
if (A)p += 'A';
else if (B) p += 'B';
else if (X) p += 'X';
}
}
coins=press(S+p);
if (coins>guardado){
A=true;
B=true;
X=true;
Y=true;
for(int c=0;c<coins-guardado;c++){
S+=p[0];
}
guardado=coins;
}
if (p[0]=='A') A=false;
else if(p[0]=='B') B=false;
else if(p[0]=='X') X=false;
else if(p[0]=='Y') Y=false;
}
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |