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) {
string p = "";
vector<char> LET = {'A', 'B', 'X', 'Y'};
int x, y, st = 0;
y = press({"AB"});
if (y >= 1) {
st = y;
p += (y == 2 ? "AB" : "A");
} else {
y = press({"BX"});
if (y >= 1) {
st = y;
p += (y == 2 ? "BX" : "B");
} else {
y = press({"XY"});
if (y >= 1) {
st = y;
p += (y == 2 ? "XY" : "X");
} else {
st = 1;
p += "Y";
}
}
}
if (p[0] == 'A')
LET.erase(LET.begin());
else if (p[0] == 'B')
LET.erase(LET.begin() + 1);
else if (p[0] == 'X')
LET.erase(LET.begin() + 2);
else
LET.erase(LET.begin() + 3);
for (int i = st; i < N; ++i) {
set<int>s;
while(true) {
random_shuffle(LET.begin(), LET.end());
if (s.count(LET[0])) {
continue;
} else if (s.size() == 2) {
if (!s.count('A') and binary_search(LET.begin(), LET.end(), 'A')) {
p += 'A';
break;
} else if (!s.count('B') and binary_search(LET.begin(), LET.end(), 'B')) {
p += 'B';
break;
} else if (!s.count('X') and binary_search(LET.begin(), LET.end(), 'X')) {
p += 'X';
break;
} else {
p += 'Y';
break;
}
}
y = press(p + LET[0] + LET[1] + LET[2]);
if (y >= i + 1) {
if (y == i + 1) {
p += LET[0];
} else if ( y == i + 2) {
p += LET[0];
p += LET[1];
++i;
} else {
p += LET[0];
p += LET[1];
p += LET[2];
i += 2;
}
break;
} else {
s.insert(LET[0]);
continue;
}
}
}
return p;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:9:7: warning: unused variable 'x' [-Wunused-variable]
9 | int x, y, st = 0;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |