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 <iostream>
using namespace std;
char choices[] = {'A', 'B', 'X', 'Y'};
std::string guess_sequence(int N) {
// trova il primo carattere
int first;
for(first = 0; first < 4; ++first) {
bool found = 1;
for(auto &c : choices) {
int val = press(string(1, c) + choices[first]);
if(val != 1) found = 0;
}
if(found)
break;
}
string ans = string(1, choices[first]);
while((int)ans.length() < N) {
for(auto &c : choices) {
if(c == choices[first]) continue;
int r = press(ans + c);
if(r == (int)ans.length()+1) {
ans += c;
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |