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) {
//first part: Getting the first letter
string first = "";
int fcoin = press("XY");
if (fcoin){
if(press("X"))
first = "X";
else
first = "Y";
}
else{
if(press("A"))
first = "A";
else
first = "B";
}
if(N == 1) return first;
string posibles = "",ans = first;
if(first == "A") posibles = "BXY";
else if(first == "B") posibles = "AXY";
else if(first == "X") posibles = "ABY";
else posibles = "ABX";
for(int i = 1; i < N -1; ++i){
string test = ans + posibles[0] + posibles[0] + ans + posibles[0] + posibles[1] + ans + posibles[0] + posibles[2] + ans + posibles[1];
int coins = press(test);
if(coins > i+1)
ans += posibles[0];
else if(coins > i)
ans += posibles[1];
else
ans += posibles[2];
}
for(int i = 0; i < 2; ++i){
if(press(ans + posibles[i]) == N) return ans + posibles[i];
}
return ans + posibles[2];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |