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>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#include "combo.h"
string letter = "ABXY";
std::string guess_sequence(int N) {
string ans{};
string actual{};
int r = press("AB");
if (r == 2) {
ans = "AB";
for (int i = 1; i < 4;++i)
actual += letter[i];
}
else if(r == 0) {
if (press("X")) {
ans = "X";
for (int i = 0; i < 4;++i)
if (i != 2)
actual += letter[i];
}
else {
ans = "Y";
for (int i = 0; i < 3;++i)
actual += letter[i];
}
}
else {
if (press("B")) {
ans = "B";
for (int i = 0; i < 4;++i)
if (i != 1)
actual += letter[i];
}
else {
ans = "A";
for (int i = 1; i < 4;++i)
actual += letter[i];
}
}
if (N == (int)ans.size()) return ans;
//cout << actual << '\n';
while((int)ans.size() < N - 1) {
string g = ans + actual[0] + actual[0] + ans + actual[0] + actual[1] + ans + actual[0] + actual[2] + ans + actual[1];
int ret = press(g);
if (ret == (int)ans.size())
ans += actual[2];
else if (ret == (int)ans.size() + 1)
ans += actual[1];
else
ans += actual[0];
}
string g = ans + actual[2];
if (press(g) == N) return g;
g = ans + actual[0];
if (press(g) == N) return g;
return ans + actual[1];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |