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 debug(x) cerr << #x << " " << x << "\n"
#define debug_with_space(x) cerr << #x << " " << x << " "
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <int, pii> piii;
const ll NMAX = 200001;
const ll INF = (1 << 30);
const ll MOD = 1000000007;
const ll BLOCK = 101;
const ll nr_of_bits = 18;
char ch[] = {'A', 'B', 'X', 'Y'};
int viz[5];
string guess_sequence(int N){
string s = "";
for(int i = 0; i < 4; i++)
viz[i] = 0;
if(press("AB")){
if(press("A")){
s += "A";
viz[0] = 1;
}else{
s += "B";
viz[1] = 1;
}
}else{
if(press("X")){
s += "X";
viz[2] = 1;
}else{
s += "Y";
viz[3] = 1;
}
}
if(N == 1)
return s;
for(int i = 2; i < N; i++){
string intrb = "";
int cnt = 2;
char a ;
char b;
char cc;
for(int i = 0; i < 4; i++){
if(!viz[i] && cnt == 2){
intrb += s;
a = ch[i];
intrb += ch[i];
cnt--;
}else if(!viz[i] && cnt == 1){
b = ch[i];
for(int x = 0; x < 4; x++){
if(!viz[x]){
intrb += s;
intrb += ch[i];
intrb += ch[x];
}
}
cnt--;
}else if(!viz[i]){
cc = ch[i];
}
}
//debug(intrb);
int ras = press(intrb);
if(ras == i){
s += a;
}else if(ras == i + 1){
s += b;
}else{
s += cc;
}
}
char a, b, cc;
int cnt = 3;
for(int i = 0; i < 4; i++){
if(!viz[i] && cnt == 3){
a = ch[i];
cnt--;
}else if(!viz[i] && cnt == 2){
b = ch[i];
cnt--;
}else if(!viz[i]){
cc = ch[i];
cnt--;
}
}
string intrb = "";
intrb += s;
if(press((intrb + a)) == N){
s += a;
}else if(press((intrb + b)) == N){
s += b;
}else{
s += cc;
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |