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 first_guess() {
static string t1("AB");
int ans = press(t1);
if (ans) {
if (press("A"))
return "A";
else
return "B";
}
else {
if (press("X"))
return "X";
else return "Y";
}
}
string guess_sequence(int n) {
string ans = first_guess();
if (n == 1) return ans;
string f = ans;
vector<string> poss;
for (string a : {"A", "B", "X", "Y"}) {
if (a != f) poss.push_back(a);
}
vector<string> comb = {poss[0]+poss[0],
poss[0]+poss[1],
poss[0]+poss[2],
poss[1]};
for (int i = 1; i < n-1; i++) {
string tmpans = ans + comb[0] + ans + comb[1] + ans + comb[2] + ans + comb[3];
int x = press(tmpans);
switch (x-i) {
case 2:
ans += poss[0];
break;
case 1:
ans += poss[1];
break;
case 0:
ans += poss[2];
break;
}
}
ans += poss[0];
if (press(ans) == n) {
return ans;
}
ans.pop_back();
ans += poss[1];
if (press(ans) == n) {
return ans;
}
ans.pop_back();
ans += poss[2];
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |