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"
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i = a;i<=b;i++)
#define ll long long int
#define pb push_back
#define vi vector<int>
#define ff first
#define ss second
#define vv vector
#define ii pair<int,int>
using namespace std;
string s = "ABXY";
string res = "";
void firstGuess(){
int x = press("AB");
if(x == 2){
res = "A";
}else if(x == 1){
x = press("A");
if(x == 0)res = "B";
else res = "A";
}else{
x = press("X");
if(x == 0)res = "Y";
else res = "X";
}
}
void reformS(){
string ss = "";
for(auto e: s){
if(!(e == res[0]))ss += e;
}
s = ss;
}
string guess_sequence(int n){
// first we guess the first character
firstGuess();
reformS();
int len = 1;
while(1){
if(len == n)break;
if(len == n-1){
int v = press(res + s[0]);
if(v == n){
res += s[0];
break;
}else{
v = press(res + s[1]);
if(v == n){
res += s[1];
break;
}else{
res += s[2];
break;
}
}
}else{
string x;
x = res;x += s[0];x += s[0];
x += res;x += s[0];x += s[1];
x += res;x += s[1];x += s[1];
int ans = press(x);
if(ans == len){
res += s[2];
len++;
}else if(ans == len + 1){
x = res;x += s[1];res += s[2];
ans = press(x);
if(ans == len){
res += s[0];res += s[2];
}else if(ans == len+1){
res += s[1];res += s[0];
}else{
res += s[1];res += s[2];
}
len += 2;
}else if(ans == len + 2){
x = res;x += s[0];x += s[0];
ans = press(x);
if(ans == len){
res += s[1];res += s[1];
}else if(ans == len +1){
res += s[0];res += s[1];
}else{
res += s[0];res += s[0];
}
len += 2;
}
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |