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>
using namespace std;
typedef long long ll;
#define v(x) vector<x>
#define pb push_back
#define mp make_pair
const ll maxint=2e18;
const ll minint =-2e18;
/*
(͡ ° ͜ʖ ͡ °): Hi, be careful of overflow.
*/
int press(string p);
/*
// comment out when submitting
int press(string p){
cout<<p<<endl;
int x;
cin>>x;
return x;
}
*/
string let[4]={"A","B","X","Y"};
string guess_sequence(int N){
string res ="";
int avoid = 0;
for(int j=0;j<4;j++){
int x = press((res+let[j]));
if(x == 1){
res+=let[j];
avoid = j;
break;
}
}
vector<string> lett;
for(int i=0;i<4;i++)if(i!=avoid)lett.push_back(let[i]);
for(int i=1;i<N;i++){
string t=res+lett[0]+res+lett[1];
int x = press(t);
if(x == i+1){
x = press(res+lett[0]);
if(x == i+1){
res+=lett[0];
}else res+=lett[1];
}else{
res += lett[2];
}
}
return res;
}
//* Notes:
//* the first character of S never reappears in it
/*
// comment out when submitting
int main(){
int n;
cin>>n;
cout<<guess_sequence(n)<<'\n';
return 0;
}
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |