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"
using namespace std;
std::string guess_sequence(int N) {
int AB = press("AB"), AX = press("AX");
std::string rez;
std::string buttons = "ABXY", remButtons;
std::string suff[4];
if(AB && AX)
rez.push_back('A');
else if(AB && !AX)
rez.push_back('B');
else if(!AB && AX)
rez.push_back('X');
else
rez.push_back('Y');
for(int i = 0; i < 4; ++i)
if(buttons[i] != rez[0])
remButtons.push_back(buttons[i]);
suff[0] = string(1,remButtons[0]) + remButtons[0];
suff[1] = string(1,remButtons[0]) + remButtons[1];
suff[2] = string(1,remButtons[0]) + remButtons[2];
suff[3] = string(1,remButtons[1]);
for(int i = 2; i <= N - 1; ++i) {
std::string query;
for(int i = 0; i < 4; ++i)
query = query + rez + suff[i];
int coins = press(query);
if(coins == i - 1)
rez.push_back(remButtons[2]);
else if(coins == i)
rez.push_back(remButtons[1]);
else
rez.push_back(remButtons[0]);
}
if(N > 1) {
AB = (press(rez + "A" + rez + "B") == N), AX = (press(rez + "A" + rez + "X") == N);
if(AB && AX)
rez.push_back('A');
else if(AB && !AX)
rez.push_back('B');
else if(!AB && AX)
rez.push_back('X');
else
rez.push_back('Y');
}
return rez;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |