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 pb push_back
using namespace std;
std::string guess_sequence(int N) {
string sol;
if(press(sol + 'A' + 'B')) {
if(press(sol + 'A')) sol += 'A';
else sol += 'B';
}else {
if(press(sol + 'X')) sol += 'X';
else sol += 'Y';
}
if(N == 1) {
return sol;
}
vector<char>vec;
if(sol[0] != 'A') vec.pb('A');
if(sol[0] != 'B') vec.pb('B');
if(sol[0] != 'X') vec.pb('X');
if(sol[0] != 'Y') vec.pb('Y');
for(int i = 2; i <= N - 1; i++) {
int X = press(sol + vec[0] + sol + vec[1] + vec[0] + sol + vec[1] + vec[1] + sol + vec[1] + vec[2]);
int siz = (int)sol.size();
if(X == siz + 1) {
sol += vec[0];
}else if(X == siz + 2) {
sol += vec[1];
}else {
sol += vec[2];
}
}
if(press(sol + "AB") == N) {
if(press(sol + 'A') == N) sol += 'A';
else sol += 'B';
}else {
if(press(sol + 'X') == N) sol += 'X';
else sol += 'Y';
}
//cout << sol << endl;
return sol;
}
//4 * (n - 2) + 7 = 4n - 1
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |