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 <iostream>
#include <string>
#include "combo.h"
std::string guess_sequence(int N) {
std::string query, knownstr, p;
char start;
int preknown = 0, score;
while(preknown<N) {
if(preknown==0) {
score = press("AB");
if(score){
score = press("A");
if(score)
start = 'A';
else
start = 'B';
}
else{
score = press("X");
if(score)
start = 'X';
else
start = 'Y';
}
knownstr.push_back(start);
preknown++;
}
else if(preknown==N-1) {
query = knownstr + "AB";
score = press(query);
if(score==preknown+1) {
score = press(knownstr + "A");
if(score==preknown+1)
knownstr.push_back('A');
else
knownstr.push_back('B');
}
else {
score = press(knownstr + "X");
if(score==preknown+1)
knownstr.push_back('X');
else
knownstr.push_back('Y');
}
preknown++;
}
else {
switch(start) {
case 'A':
query = knownstr + "BB" + knownstr + "BX" + knownstr + "BY" + knownstr + "X";
score = press(query);
if(score==preknown+2)
knownstr.push_back('B');
else if(score==preknown+1)
knownstr.push_back('X');
else
knownstr.push_back('Y');
break;
case 'B':
query = knownstr + "AA" + knownstr + "AX" + knownstr + "AY" + knownstr + "X";
score = press(query);
if(score==preknown+2)
knownstr.push_back('A');
else if(score==preknown+1)
knownstr.push_back('X');
else
knownstr.push_back('Y');
break;
case 'X':
query = knownstr + "AA" + knownstr + "AB" + knownstr + "AY" + knownstr + "B";
score = press(query);
if(score==preknown+2)
knownstr.push_back('A');
else if(score==preknown+1)
knownstr.push_back('B');
else
knownstr.push_back('Y');
break;
case 'Y':
query = knownstr + "AA" + knownstr + "AB" + knownstr + "AX" + knownstr + "B";
score = press(query);
if(score==preknown+2)
knownstr.push_back('A');
else if(score==preknown+1)
knownstr.push_back('B');
else
knownstr.push_back('X');
break;
}
preknown++;
}
}
return knownstr;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |