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;
// 1 < N <= 2000
// Each character of the string is A, B, X, or Y
// The first character of S never reappears in S
string guess_sequence(int N) {
// N: length of string S
// Function is called exactly once for each test case
// Function should return the string S
string seq = "";
if (press("AAB") > 0) {
if (press("A") == 1) {
seq += "A";
int n = 1; // return value of press for press("A")
// seq of n == N is seq
vector<string> allowed_cars = {"B", "X", "Y"};
while (n < N - 1) {
string temp = "";
temp += seq + allowed_cars[0] + allowed_cars[0] + seq + allowed_cars[0] + allowed_cars[1] + seq
+ allowed_cars[0] + allowed_cars[2] + seq + allowed_cars[1];
// cout << temp << '\n';
int yes = 2 - press(temp) + n;
seq += allowed_cars[yes];
n++;
}
if (press(seq + allowed_cars[0]) == N) {
return seq + allowed_cars[0];
}
else if (press(seq + allowed_cars[1]) == N) {
return seq + allowed_cars[1];
}
else {
return seq + allowed_cars[2];
}
}
else {
seq += "B";
int n = 1; // return value of press for press("A")
// seq of n == N is seq
vector<string> allowed_cars = {"A", "X", "Y"};
while (n < N - 1) {
string temp = "";
temp += seq + allowed_cars[0] + allowed_cars[0] + seq + allowed_cars[0] + allowed_cars[1] + seq
+ allowed_cars[0] + allowed_cars[2] + seq + allowed_cars[1];
seq += allowed_cars[2 - press(temp) + n];
n++;
}
if (press(seq + allowed_cars[0]) == N) {
return seq + allowed_cars[0];
}
else if (press(seq + allowed_cars[1]) == N) {
return seq + allowed_cars[1];
}
else {
return seq + allowed_cars[2];
}
}
}
else {
if (press("X") == 1) {
seq += "X";
int n = 1; // return value of press for press("A")
// seq of n == N is seq
vector<string> allowed_cars = {"A", "B", "Y"};
while (n < N - 1) {
string temp = "";
temp += seq + allowed_cars[0] + allowed_cars[0] + seq + allowed_cars[0] + allowed_cars[1] + seq
+ allowed_cars[0] + allowed_cars[2] + seq + allowed_cars[1];
seq += allowed_cars[2 - press(temp) + n];
n++;
}
if (press(seq + allowed_cars[0]) == N) {
return seq + allowed_cars[0];
}
else if (press(seq + allowed_cars[1]) == N) {
return seq + allowed_cars[1];
}
else {
return seq + allowed_cars[2];
}
}
else {
seq += "Y";
int n = 1; // return value of press for press("A")
// seq of n == N is seq
vector<string> allowed_cars = {"A", "B", "X"};
while (n < N - 1) {
string temp = "";
temp += seq + allowed_cars[0] + allowed_cars[0] + seq + allowed_cars[0] + allowed_cars[1] + seq
+ allowed_cars[0] + allowed_cars[2] + seq + allowed_cars[1];
seq += allowed_cars[2 - press(temp) + n];
n++;
}
if (press(seq + allowed_cars[0]) == N) {
return seq + allowed_cars[0];
}
else if (press(seq + allowed_cars[1]) == N) {
return seq + allowed_cars[1];
}
else {
return seq + allowed_cars[2];
}
}
}
return seq;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |