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 <bits/stdc++.h>
#include "combo.h"
using namespace std;
string s;
/*long long press(string t){
cout << t << endl;
long long ans;
cin >> ans;
return ans;
}*/
long long ask(string t){
return (long long) press(t);
}
string guess_sequence(int N){
long long a=0,b=0,x=0,y=0;
long long n = N;
if(ask("AB") >= 1){
if(ask("B") == 1){
b = 1;
}
else{
a = 1;
}
}
else{
if(ask("X") == 1){
x = 1;
}
else{
y = 1;
}
}
if(a){
s += "A";
if(n == 1){
return s;
}
for(long i = 1; i <= n-2; i++){
string r = s + "B" + s + "XY" + s + "XB" + s + "XX";
long long rez = ask(r);
if(rez == i+1){
s += "B";
}
if(rez == i+2){
s += "X";
}
if(rez == i){
s += "Y";
}
}
string r = s+"B",e = s+"X";
long long r1 = ask(r);
if(r1 == n){
return r;
}
long long r2 = ask(e);
if(r2 == n){
return e;
}
return s+"Y";
}
if(b){
s += "B";
if(n == 1){
return s;
}
for(long i = 1; i <= n-2; i++){
string r = s + "A" + s + "XY" + s + "XA" + s + "XX";
long long rez = ask(r);
if(rez == i+1){
s += "A";
}
if(rez == i+2){
s += "X";
}
if(rez == i){
s += "Y";
}
}
string r = s+"A",e = s+"X";
long long r1 = ask(r);
if(r1 == n){
return r;
}
long long r2 = ask(e);
if(r2 == n){
return e;
}
return s+"Y";
}
if(x){
s += "X";
if(n == 1){
return s;
}
for(long i = 1; i <= n-2; i++){
string r = s + "A" + s + "BY" + s + "BA" + s + "BB";
long long rez = ask(r);
if(rez == i+1){
s += "A";
}
if(rez == i+2){
s += "B";
}
if(rez == i){
s += "Y";
}
}
string r = s+"B",e = s+"Y";
long long r1 = ask(r);
if(r1 == n){
return r;
}
long long r2 = ask(e);
if(r2 == n){
return e;
}
return s+"A";
}
if(y){
s += "Y";
if(n == 1){
return s;
}
for(long i = 1; i <= n-2; i++){
string r = s + "A" + s + "BX" + s + "BA" + s + "BB";
long long rez = ask(r);
if(rez == i+1){
s += "A";
}
if(rez == i+2){
s += "B";
}
if(rez == i){
s += "X";
}
}
string r = s+"B",e = s+"X";
long long r1 = ask(r);
if(r1 == n){
return r;
}
long long r2 = ask(e);
if(r2 == n){
return e;
}
return s+"A";
}
}
/*int main(){
cout << guess_sequence(1) << endl;
}*/
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:149:1: warning: control reaches end of non-void function [-Wreturn-type]
149 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |