이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#include "combo.h"
using namespace std;
string guess_sequence(int N) {
string ans;
char start = 'Y';
int a = press("AB");
if (a >= 1) {
a = press("B");
if (a == 1) {
start = 'B';
}
else {
start = 'A';
}
}
else {
a = press("X");
if (a == 1) {
start = 'X';
}
else {
start = 'Y';
}
}
if (N == 1) {
ans.push_back(start);
return ans;
}
if (start == 'A') {
ans = "A";
for (int i=1; i<N-1; i++) {
string A = ans + "B";
string B = ans + "XB";
string C = ans + "XY";
string D = ans + "XX";
A = A + B + C + D;
a = press(A);
if (a == i) {
ans = ans + "Y";
}
if (a == i+1) {
ans = ans + "B";
}
if (a >= i+2) {
ans = ans + "X";
}
}
string X = ans + "X";
string Y = ans + "Y";
string add = X + Y;
a = press(add);
if (a == N) {
a = press(X);
if (a == N) {
ans = X;
}
else {
ans = Y;
}
}
else {
ans = ans + "B";
}
}
else if (start == 'B') {
ans = "B";
for (int i=1; i<N-1; i++) {
string A = ans + "A";
string B = ans + "XA";
string C = ans + "XY";
string D = ans + "XX";
A = A + B + C + D;
a = press(A);
if (a == i) {
ans = ans + "Y";
}
if (a == i+1) {
ans = ans + "A";
}
if (a >= i+2) {
ans = ans + "X";
}
}
string X = ans + "X";
string Y = ans + "Y";
string add = X + Y;
a = press(add);
if (a == N) {
a = press(X);
if (a == N) {
ans = X;
}
else {
ans = Y;
}
}
else {
ans = ans + "A";
}
}
else if (start == 'X') {
ans = "X";
for (int i=1; i<N-1; i++) {
string A = ans + "B";
string B = ans + "AB";
string C = ans + "AY";
string D = ans + "AA";
A = A + B + C + D;
a = press(A);
if (a == i) {
ans = ans + "Y";
}
if (a == i+1) {
ans = ans + "B";
}
if (a >= i+2) {
ans = ans + "A";
}
}
string X = ans + "A";
string Y = ans + "Y";
string add = X + Y;
a = press(add);
if (a == N) {
a = press(X);
if (a == N) {
ans = X;
}
else {
ans = Y;
}
}
else {
ans = ans + "B";
}
}
else if (start == 'Y') {
ans = "Y";
for (int i=1; i<N-1; i++) {
string A = ans + "B";
string B = ans + "XB";
string C = ans + "XA";
string D = ans + "XX";
A = A + B + C + D;
a = press(A);
if (a == i) {
ans = ans + "A";
}
if (a == i+1) {
ans = ans + "B";
}
if (a >= i+2) {
ans = ans + "X";
}
}
string X = ans + "X";
string Y = ans + "A";
string add = X + Y;
a = press(add);
if (a == N) {
a = press(X);
if (a == N) {
ans = X;
}
else {
ans = Y;
}
}
else {
ans = ans + "B";
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |