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 ;
std::string guess_sequence(int N) {
string p = "";
char A = 'A' , B = 'B' , X = 'X' , Y = 'Y';
string first = "AB" , second = "XY";
int coins = press(first);
if(coins){
coins = press("A");
if(coins)p += 'A';
else p += 'B' , swap(A , B);
}
else {
coins = press("X");
if(coins) p+= 'X' , swap(A , X);
else p += 'Y' , swap(A , Y);
}
coins = 1 ;
if(N == 1)return p ;
int curr = coins ;
string S = p ;
while(curr < N - 1){
p = S + B ;
p += S + X + B ;
p += S + X + X ;
p += S + X + Y ;
coins = press(p);
if(coins - curr == 0)S.push_back(Y);
else if(coins - curr == 1)S.push_back(B);
else S.push_back(X);
curr ++ ;
}
S += B ;
coins = press(S );
if(coins == N)return S ;
S.pop_back() ;
S += X ;
coins = press(S);
if(coins == N)return S ;
S.pop_back();
S.push_back(Y);
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |