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 <bits/stdc++.h>
using namespace std;
string guess_sequence(int N) {
string ans = "AB";
int res = press(ans);
// cout << "RES1: " << res << '\n';
if (res >= 1) {
ans = "A";
res = press(ans);
if (res == 0)
ans = "B";
} else {
ans = "X";
res = press(ans);
if (res == 0)
ans = "Y";
}
vector <char> c(3);
if (ans[0] == 'A')
c = {'B', 'X', 'Y'};
if (ans[0] == 'B')
c = {'A', 'X', 'Y'};
if (ans[0] == 'X')
c = {'A', 'B', 'Y'};
if (ans[0] == 'Y')
c = {'A', 'B', 'X'};
for (int i = 1; i < N; i++) {
string s = ans;
// s.push_back('B');
// s.append(ans);
// s.append("XB");
// s.append(ans);
// s.append("XX");
// s.append(ans);
// s.append("XY");
// cout << "guess: " << s << '\n';
// res = press(s);
// cout << "result: " << res << '\n';
// if (res == 1)
// ans.push_back('B');
// else if (res == 2)
// ans.push_back('X');
// else
// ans.push_back('Y');
for (int j = 0; j < 2; j++) {
s.push_back(c[j]);
res = press(s);
if (res == i+1) {
ans.push_back(c[j]);
break;
}
s.pop_back();
}
if ((int)ans.size() < i+1)
ans.push_back(c[2]);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |