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<string>
#include <assert.h>
#include <iostream>
#include <algorithm>
using namespace std;
string FindFirstChar() {
if (press("AB")) {
if (press("A")) return "A";
else return "B";
}
if (press("X")) return "X";
return "Y";
}
string guess_sequence(int N) {
string now = FindFirstChar();
if (N == 1) return now;
string remaining = "ABXY";
remaining.erase(find(remaining.begin(), remaining.end(), now[0]));
assert(remaining.size() == 3);
for (int i = 2; i < N; i++) {
string current = (now + remaining[0])
+ (now + remaining[1] + remaining[0])
+ (now + remaining[1] + remaining[1])
+ (now + remaining[1] + remaining[2]);
int coin = press(current);
if (coin == i - 1) now.push_back(remaining[2]);
else if (coin == i) now.push_back(remaining[0]);
else now.push_back(remaining[1]);
}
for (int i = 0; i < 2; i++) {
if (press(now + remaining[i]) == N) return now + remaining[i];
}
return now + remaining[2];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |