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 <vector>
#include <iostream>
using namespace std;
string guess_sequence(int N) {
vector<char> letters = {'A', 'B', 'X', 'Y'};
string start1 = "AB";
int score = press(start1);
string p = "";
if (score > 0) {
string start2 = "B";
int score = press(start2);
if (score > 0) {
letters.erase(letters.begin() + 1);
p += "B";
} else {
letters.erase(letters.begin());
p += "A";
}
} else {
string start2 = "X";
int score = press(start2);
if (score > 0) {
letters.erase(letters.begin() + 2);
p += "X";
} else {
letters.erase(letters.begin() + 3);
p += "Y";
}
}
if (N == 1) {
return p;
}
for (int i = 1; i < N-1; i++) {
string p1 = p + letters[0] + p + letters[1] + letters[0] + p + letters[1] + letters[1] + p + letters[1] + letters[2];
int score = press(p1);
if (score == i) {
p += letters[2];
} else if (score == i+1) {
p += letters[0];
} else if (score == i+2) {
p += letters[1];
}
}
string end1 = p + letters[0];
score = press(end1);
if (score == N) {
return end1;
}
string end2 = p + letters[1];
score = press(end2);
if (score == N) {
return end2;
}
return p + letters[2];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |