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;
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include "combo.h"
const char c[4] = {'A', 'B', 'X', 'Y'};
string guess_sequence(int n){
string res = "";
char fir;
int firstid = -1, secondid = -1;
int a1 = press("AB");
if(a1 >= 1){
int a2 = press("A");
if(a2 > 0){
res += "A"; fir = 'A';
}else{
res += "B"; fir = 'B';
}
}else{
int a2 = press("X");
if(a2 > 0){
res += "X"; fir = 'X';
}else{
res += "Y"; fir = 'Y';
}
}
forr(i, 0, 4){
if(c[i] != fir){
if(firstid == -1)firstid = i;
else if(secondid == -1) secondid = i;
}
}
int thirdid;
if(fir == 'Y')thirdid = 2;
else thirdid = 3;
assert(firstid != secondid && secondid != thirdid);
for(int i = 1; i < n - 1; i++){
string guess = "";
guess += res; guess += c[firstid];
forr(j, 0, 3){
guess += res; guess += c[secondid];
if(!j)guess += c[firstid];
else if(j == 1)guess += c[secondid];
else guess += c[thirdid];
}
int ans = press(guess);
if(ans == i){
res += c[thirdid];
}else if(ans == i + 1){
res += c[firstid];
}else{
res += c[secondid];
}
}
if(n == 1)return(res);
string guess;
guess += res; guess += c[firstid]; guess += res; guess += c[secondid];
int ans = press(guess);
if(ans == n - 1){
res += c[thirdid];
}else{
guess = res + c[firstid];
ans = press(guess);
if(ans == n - 1){
res += c[secondid];
}else{
res += c[firstid];
}
}
return(res);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |