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>
#ifndef LOCALME
#include <combo.h>
#endif // LOCALME
#define oo 1000000007
#define ll long long
#define ld long double
#define ii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define mp make_pair
#define vi vector<int>
#define vii vector<ii>
#define sz(a) (int)(a.size())
#define pb push_back
#define fto(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define fdto(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)
#define bug(x) "["#x" = "<<(x)<<"] "
#define maxN 10005
using namespace std;
char chrs[] = {'A', 'B', 'X', 'Y'};
#ifdef LOCALME
int press(const string &p) {
cout << p << "\n";
fflush(stdout);
int x; cin >> x;
return x;
}
#endif // LOCALME
string guess_sequence(int n) {
string s = "";
int i = -1;
int matches = press("AB");
if (matches >= 1) {
matches = press("A");
if (matches == 1) s += "A", i = 0;
else s += "B", i = 1;
} else {
matches = press("X");
if (matches == 1) s += "X", i = 2;
else s += "Y", i = 3;
}
fto(j, 2, n-1) {
int len = s.length();
matches = press(s+chrs[(i+1)%4] + s+chrs[(i+2)%4]+chrs[(i+1)%4] + s+chrs[(i+2)%4]+chrs[(i+2)%4] + s+chrs[(i+2)%4]+chrs[(i+3)%4]);
if (matches == len) {
s += chrs[(i+3)%4];
} else if (matches == len+1) {
s += chrs[(i+1)%4];
} else {
s += chrs[(i+2)%4];
}
}
if (n >= 2) {
int matches = press(s+"A" + s+"B");
if (matches >= (int)s.length()+1) {
matches = press(s + "A");
if (matches == (int)s.length()+1) s += "A", i = 0;
else s += "B", i = 1;
} else {
matches = press(s + "X");
if (matches == (int)s.length()+1) s += "X", i = 2;
else s += "Y", i = 3;
}
}
return s;
}
#ifdef LOCALME
int main() {
//ios_base::sync_with_stdio(false); cin.tie(NULL);
int n; cin >> n;
string s = guess_sequence(n);
cout << s << "\n";
return 0;
}
#endif
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |