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 <string>
#include <iostream>
using namespace std;
std::string guess_sequence(int N) {
// step #1. first letter
int gi1 = press("AB"), gi2 = press("AX");
char ci = '?';
if(gi1 != 0 && gi2 != 0) ci = 'A';
if(gi1 != 0 && gi2 == 0) ci = 'B';
if(gi1 == 0 && gi2 != 0) ci = 'X';
if(gi1 == 0 && gi2 == 0) ci = 'Y';
// step #2. second to (N-1)-th letters
string current(1, ci);
for(int i = 1; i < N - 1; ++i) {
char cn1 = '?', cn2 = '?', cn3 = '?';
if(ci == 'A') cn1 = 'B', cn2 = 'X', cn3 = 'Y';
if(ci == 'B') cn1 = 'X', cn2 = 'Y', cn3 = 'A';
if(ci == 'X') cn1 = 'Y', cn2 = 'A', cn3 = 'B';
if(ci == 'Y') cn1 = 'A', cn2 = 'B', cn3 = 'X';
int g = press(current + cn1 + cn1 + current + cn1 + cn2 + current + cn1 + cn3 + current + cn2);
if(g == i + 2) current += cn1;
if(g == i + 1) current += cn2;
if(g == i) current += cn3;
};
// step #3. N-th letter
if(N >= 2) {
int gl1 = press(current + "A" + current + "B");
int gl2 = press(current + "A" + current + "X");
if(gl1 == N && gl2 == N) current += "A";
if(gl1 == N && gl2 != N) current += "B";
if(gl1 != N && gl2 == N) current += "X";
if(gl1 != N && gl2 != N) current += "Y";
}
return current;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |