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 <bits/stdc++.h>
#include "combo.h"
using namespace std;
string guess_sequence(int n){
string s = string(n,' ');
if(press("AB")){
if(press("A")) s[0] = 'A';
else s[0] = 'B';
}else{
if(press("X")) s[0] = 'X';
else s[0] = 'Y';
}
if(n == 1) return s;
string c = "ABXY";
c.erase(remove(c.begin(),c.end(),s[0]),c.end());
for(int i = 1; i < n - 1; i++){
string q = "";
for(int j = 0; j < 3; j++){
q += s.substr(0,i) + c[0] + c[j];
}
q += s.substr(0,i) + c[1];
int res = press(q);
if(res == i) s[i] = c[2];
else if(res == i + 1) s[i] = c[1];
else s[i] = c[0];
}
for(int i = 0; i < 2; i++){
s[n-1] = c[i];
if(press(s) == n) return s;
}
s[n-1] = c[2];
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |