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;
char button[] = {'A', 'B', 'X', 'Y'};
int start, n1, n2, n3;
string guess_sequence(int N) {
string ans = "";
// find character #1
if (press("AB")) {
if (press("A")) {
ans.push_back('A');
start = 0;
} else {
ans.push_back('B');
start = 1;
}
} else {
if (press("X")) {
ans.push_back('X');
start = 2;
} else {
ans.push_back('Y');
start = 3;
}
}
n1 = (start + 1) % 4;
n2 = (start + 2) % 4;
n3 = (start + 3) % 4;
//cout << ans << '\n';
// find character #[2..N-1]
for (int i = 2; i < N; i++) {
string query = ans;
query.push_back(button[n1]);
query += ans;
query.push_back(button[n2]);
query.push_back(button[n1]);
query += ans;
query.push_back(button[n2]);
query.push_back(button[n2]);
query += ans;
query.push_back(button[n2]);
query.push_back(button[n3]);
int coins = press(query);
if (coins == i+1) {
ans.push_back(button[n2]);
} else if (coins == i) {
ans.push_back(button[n1]);
} else {
ans.push_back(button[n3]);
}
//cout << ans << '\n';
}
// find character #N
if (N != 1) {
string query = ans;
query.push_back(button[n1]);
query += ans;
query.push_back(button[n2]);
if (press(query) == N) {
query = ans;
query.push_back(button[n1]);
if (press(query) == N) {
ans.push_back(button[n1]);
} else {
ans.push_back(button[n2]);
}
} else {
ans.push_back(button[n3]);
}
//cout << ans << '\n';
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |