제출 #552285

#제출 시각아이디문제언어결과실행 시간메모리
552285lethinh05콤보 (IOI18_combo)C++11
10 / 100
55 ms452 KiB
#include <bits/stdc++.h>

#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 100005

using namespace std;

char chrs[] = {'A', 'B', 'X', 'Y'};

int press(string p);

#ifdef LOCALME
int press(string p) {
    cout << p << "\n";
    fflush(stdout);
    int x; cin >> x;
    return x;
}
#endif // LOCALME

string guess_sequence(int n) {
    string s = "";
    fto(i, 0, 3) {
        string p(1, chrs[i]);
        int matches = press(p);
        fflush(stdout);
        if (matches == 1) {
            s += chrs[i];
            break;
        }
    }

    fto(i, 1, n-1) {
        fto(i, 0, 3) {
            if (chrs[i] == s[0]) continue;

            string p = s + chrs[i];
            int matches = press(p);
            fflush(stdout);
            if (matches == sz(p)) {
                s += chrs[i];
                break;
            }
        }
    }

    return s;
}

#ifdef LOCALME
int main() {
    int n; cin >> n;
    string res = guess_sequence(n);
    cout << res << "\n";
    fflush(stdout);
    return 0;
}
#endif

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...