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;
string guess_sequence(int n) {
int coins;
vector<char> c = {'A', 'B', 'X', 'Y'};
string ans = "";
coins = press(ans + "A" + ans + "B");
if (coins - ans.size()) {
coins = press(ans + "A");
if (coins - ans.size()) ans += "A";
else ans += "B";
} else {
coins = press(ans + "X");
if (coins - ans.size()) ans += "X";
else ans += "Y";
}
vector<string> d, e;
if (ans == "A") {
d = {"B", "XB", "XX", "XY"};
e = {"Y", "B", "X"};
} else if (ans == "B") {
d = {"A", "XA", "XX", "XY"};
e = {"Y", "A", "X"};
} else if (ans == "X") {
d = {"A", "YA", "YB", "YY"};
e = {"B", "A", "Y"};
} else {
d = {"A", "XA", "XB", "XX"};
e = {"B", "A", "X"};
}
while ((int)ans.size() < n-1) {
coins = press(ans + d[0] + ans + d[1] + ans + d[2] + ans + d[3]);
ans += e[coins - ans.size()];
}
if ((int)ans.size() == n-1) {
coins = press(ans + "A" + ans + "B");
if (coins - ans.size()) {
coins = press(ans + "A");
if (coins - ans.size()) ans += "A";
else ans += "B";
} else {
coins = press(ans + "X");
if (coins - ans.size()) ans += "X";
else ans += "Y";
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |