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;
vector<char> letters = {'A', 'B', 'X', 'Y'};
string guess_sequence(int N) {
string p = "";
int coins;
// Find first character
for (int i = 0; i < (int) letters.size() - 1; i++) {
if ((coins = press(p + letters[i])) > 0) {
p += letters[i];
letters.erase(letters.begin() + i);
break;
}
}
if ((int) p.size() == 0) {
p += letters[letters.size() - 1];
letters.pop_back();
}
// Find characters 2...N-1
for (int i = 2; i <= N - 1; i++) {
string guess = p + letters[0] + p + letters[1] + letters[0] + p + letters[1] + letters[1] + p + letters[1] + letters[2];
coins = press(guess) - p.size();
switch (coins) {
case 0:
p += letters[2];
break;
case 1:
p += letters[0];
break;
case 2:
p += letters[1];
break;
}
}
// Find last character
for (int i = 0; i < (int) letters.size() - 1; i++) {
if ((coins = press(p + letters[i])) == N) {
p += letters[i];
letters.erase(letters.begin() + i);
break;
}
}
if ((int) p.size() == N - 1) {
p += letters[letters.size() - 1];
}
string S = p;
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |