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>
#define pb push_back
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll INF = (ll)1<<62;
const ll MOD = 1e9+7;
const int iINF = 1<<30;
const double PI = 3.14159265359;
int press(string);
string guess_sequence(int n){
string curr = "";
if(press("AB")){
if(press("A")) curr = "A";
else curr = "B";
}
else{
if(press("X")) curr = "X";
else curr = "Y";
}
if((int)curr.size() == n) return curr;
string adder[4];
string rem = "";
if(curr == "A"){
adder[0] = "BB"; adder[1] = "BX"; adder[2] = "BY"; adder[3] = "X"; rem = "Y";
}
else if(curr == "B"){
adder[0] = "AA"; adder[1] = "AX"; adder[2] = "AY"; adder[3] = "X"; rem = "Y";
}
else if(curr == "X"){
adder[0] = "AA"; adder[1] = "AB"; adder[2] = "AY"; adder[3] = "Y"; rem = "B";
}
else{
adder[0] = "AA"; adder[1] = "AB"; adder[2] = "AX"; adder[3] = "X"; rem = "B";
}
while((int)curr.size() < n-1){
string q = curr + adder[0] + curr + adder[1] + curr + adder[2] + curr + adder[3];
int resp = press(q);
if(resp == (int)curr.size()+2)
curr += string(1, adder[0][0]);
else if(resp == (int)curr.size()+1)
curr += string(1, adder[3][0]);
else
curr += rem;
}
if(curr[0] == 'A'){
adder[0] = "B"; adder[1] = "X"; rem = "Y";
}
else if(curr[0] == 'B'){
adder[0] = "A"; adder[1] = "X"; rem = "Y";
}
else if(curr[0] == 'X'){
adder[0] = "A"; adder[1] = "B"; rem = "Y";
}
else{
adder[0] = "A"; adder[1] = "B"; rem = "X";
}
if(press(curr+adder[0]) == n)
return curr + adder[0];
if(press(curr+adder[1]) == n)
return curr + adder[1];
return curr + rem;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |