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;
//int press (string a) {
// cout << a;
// int b;
// cin >> b;
// return b;
//}
string guess_sequence(int n) {
string rj = "";
vector<string> svi {"A", "B", "X", "Y"};
string poc;
int a = press ("AB"), b;
if (a) {
b = press ("A");
if (b) poc = "A";
else poc = "B";
}
else {
b = press ("X");
if (b) poc = "X";
else poc = "Y";
}
rj += poc;
vector<string> ostali;
for (auto it: svi) {
if (it != poc) ostali.push_back(it);
}
int dul = rj.size ();
if (dul == n) return rj;
while (dul < n - 1) {
string p = rj + ostali[0];
for (int i = 0; i < 3; i++) p += rj + ostali[1] + ostali[i];
int ret = press (p);
if (ret == dul) rj += ostali[2];
if (ret == dul + 1) rj += ostali[0];
if (ret == dul + 2) rj += ostali[1];
dul++;
}
if (press (rj + ostali[0]) == n) rj += ostali[0];
else if (press (rj + ostali[1]) == n) rj += ostali[1];
else rj += ostali[2];
return rj;
}
//int main () {
// int n;
// cin >> n;
// cout << guess_sequence (n);
// return 0;
//}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |