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 <vector>
#include <algorithm>
#include <string>
using namespace std;
std::string guess_sequence(int N) {
string s = "";
vector<char> rem{ 'A', 'B', 'X', 'Y' };
if (press("AB")) {
if (press("A")) {
s.push_back('A');
}
else s.push_back('B');
}
else {
if (press("X")) {
s.push_back('X');
}
else s.push_back('Y');
}
if (N == 1) return s;
rem.erase(find(rem.begin(), rem.end(), s[0]));
for (int i = 1; i < N - 1; i++) {
int len = s.size();
string check = s;
check.push_back(rem[0]);
check.push_back(rem[0]);
check += s;
check.push_back(rem[0]);
check.push_back(rem[1]);
check += s;
check.push_back(rem[0]);
check.push_back(rem[2]);
check += s;
check.push_back(rem[2]);
int newLen = press(check);
if (newLen == len + 2) s.push_back(rem[0]);
else if (newLen == len + 1) s.push_back(rem[2]);
else s.push_back(rem[1]);
}
string finalAns = s;
finalAns.push_back(rem[0]);
if (press(finalAns) > (int)s.length()) {
return finalAns;
}
finalAns.pop_back();
finalAns.push_back(rem[1]);
if (press(finalAns) > (int)s.length()) {
return finalAns;
}
finalAns.pop_back();
finalAns.push_back(rem[2]);
return finalAns;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |