이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 == 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... |