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;
typedef long long int ll;
string guess_sequence(int N) {
string S (N,'X');
int res;
res = press("AB");
if (res>0){
res = press("A");
if (res>0) S[0] = 'A';
else S[0] = 'B';
}
else{
res = press("X");
if (res>0) S[0] = 'X';
else S[0] = 'Y';
}
if (N==1) return S;
char a,b,c;
if (S[0]=='A') {a='B';b='X';c='Y';}
if (S[0]=='B') {a='A';b='X';c='Y';}
if (S[0]=='X') {a='A';b='B';c='Y';}
if (S[0]=='Y') {a='A';b='B';c='X';}
for (int x=1;x<N-1;x++){
string p(4*x+7,'X');
int ter=0;
for (int y=0;y<x;y++)p[ter++] = S[y];
p[ter++] = a;
p[ter++] = a;
for (int y=0;y<x;y++)p[ter++] = S[y];
p[ter++] = a;
p[ter++] = b;
for (int y=0;y<x;y++)p[ter++] = S[y];
p[ter++] = a;
p[ter++] = c;
for (int y=0;y<x;y++)p[ter++] = S[y];
p[ter++] = b;
res = press(p);
if (res == x+2){
S[x] = a;
}
if (res == x+1){
S[x] = b;
}
if (res == x){
S[x] = c;
}
}
string p(2*N,'X');
int ter=0;
for (int y=0;y<N-1;y++)p[ter++] = S[y];
p[ter++] = a;
for (int y=0;y<N-1;y++)p[ter++] = S[y];
p[ter++] = b;
res = press(p);
if (res==N){
string p(N,'X');
ter = 0;
for (int y=0;y<N-1;y++)p[ter++] = S[y];
p[ter++] = a;
res = press(p);
if (res==N) S[N-1] = a;
else S[N-1] = b;
}
else S[N-1] = c;
//cout << "meine odp: " << S << '\n';
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |