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;
/*
int press(string code) {
cout << "Common in code "<<code<<": ";
int n;
cin >> n;
return n;
}*/
string guess_sequence(int N) {
//test case
if(N==1) {
if(press("A")) return "A";
if(press("B")) return "B";
if(press("X")) return "X";
return "Y";
}
string code="";
string opts;
//get first char
if(press("AB")) {
if(press("A")) {code="A";opts="BXY";}
else {code="B";opts="AXY";}
} else {
if(press("X")) {code="X";opts="ABY";}
else {code="Y";opts="ABX";}
}
//get middle chars
for(int i=1; i<N-1; i++) {
string p=code+opts[1];
for(char c:opts) {p+=code+opts[2]+c;}
int val=press(p);
if(val==i) code+=opts[0];
else if(val==i+1) code+=opts[1];
else code+=opts[2];
}
//get last char
if(press(code+opts[0])==N) code+=opts[0];
else if(press(code+opts[1])==N) code+=opts[1];
else code+=opts[2];
return code;
}
/*
int main() {
string code="ABXYY";
cout << code << endl;
cout << guess_sequence(5) << endl;
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |