이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |