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 "combo.h"
#include <bits/stdc++.h>
using namespace std;
std::string guess_sequence(int N) {
std::string p = "";
std::vector<char> vec = {'A','B','X','Y'};
char st;
int coin = press("AB");
if (coin == 1){
coin = press("A");
if (coin == 1){
st = 'A';
}
else{
st = 'B';
}
}
else if (coin != 2){
coin = press("X");
if (coin == 1){
st = 'X';
}
else{
st = 'Y';
}
}
if (coin == 2){
st = 'A';
}
auto it = find(vec.begin(),vec.end(),st);
vec.erase(it);
p.push_back(st);
if (coin == 2){
p.push_back('B');
}
for (int i = p.size(); i<N-1; i++){
string guess;
string one = p; one.push_back(vec[0]); one.push_back(vec[0]);
string two = p; two.push_back(vec[0]); two.push_back(vec[1]);
string three = p; three.push_back(vec[0]); three.push_back(vec[2]);
string four = p; four.push_back(vec[1]);
guess = one + two + three + four;
int res = press(guess);
char nxt;
if (res == i){
nxt = vec[2];
}
else if (res == i+1){
nxt = vec[1];
}
else{
nxt = vec[0];
}
p.push_back(nxt);
}
int sz = p.size();
if (sz == N){
return p;
}
char lst;
string guess;
string ek = p; ek.push_back(vec[0]);
string doo = p; doo.push_back(vec[1]);
guess = ek+doo;
int c = press(guess);
if (c == sz){
lst = vec[2];
}
else{
guess = p; guess.push_back(vec[0]);
c = press(guess);
if (c == sz){
lst = vec[1];
}
else{
lst = vec[0];
}
}
p.push_back(lst);
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |