제출 #1323971

#제출 시각아이디문제언어결과실행 시간메모리
1323971QuocSenseiCombo (IOI18_combo)C++20
5 / 100
0 ms400 KiB
#include <bits/stdc++.h>

#define FILENAME "CODE"
#define ll long long 
#define el cout << '\n'
#define ii pair<ll, ll>
#define fi first 
#define se second 
#define pb push_back
#define YES cout << "YES", el
#define NO cout << "NO", el
#define print_type cout
#define print_el print_type << '\n'
#define DEBUG(...) [](auto && ... x) {int i = 0; ((print_type << (i++ ? " " : "") << x), ...), print_el;} (__VA_ARGS__)
#define bit(mask, i) (((mask) >> (i)) & 1)
#define BIT(n) (1ll << (n))

using namespace std;

const bool is_brute = 0;
const bool multi_test = 0;

const bool is_gen = 1;

string ans;

int press(string p);

string guess_sequence(int N)
{
    string ch = "ABXY";
    string ans = "";
    if (press("AB"))
    {
        if (press("B"))
            swap(ch[0], ch[1]);
    }
    else
    {
        if (press("X"))
            swap(ch[0], ch[2]);
        else
            swap(ch[0], ch[3]);
    }
    ans = ch[0];
    while (ans.size() < N - 1)
    {
        int state = press(ans + ch[1] + ch[1] + ans + ch[1] + ch[2] + ans + ch[1] + ch[3] + ans + ch[2]);
        if (state == ans.size())
            ans.push_back(ch[3]);
        else if (state == ans.size() + 1)
            ans.push_back(ch[2]);
        else
            ans.push_back(ch[1]);
    }
    if (press(ans + ch[1]) == N)
        ans.push_back(ch[1]);
    else if (press(ans + ch[2]) == N)
        ans.push_back(ch[2]);
    else
        ans.push_back(ch[3]);
    return ans;
}

void gen()
{
    cin >> ans;
    if (ans == guess_sequence(ans.size()))
        cout << "PASSED\n";
    else
        cout << "WRONG\n";
}

void solve()
{
    gen();
}

#ifdef LOCAL
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen(FILENAME".INP", "r"))
    {
        freopen(FILENAME".INP", "r", stdin);
        if (is_brute)
            freopen(FILENAME"_TRAU.OUT", "w", stdout);
        else
            freopen(FILENAME".OUT", "w", stdout);
    }

    int ntest;
    if (multi_test)
        cin >> ntest;
    else
        ntest = 1;
    for (int itest = 1; itest <= ntest; itest++)
    {
        // cout << itest, el;
        solve();
    }
}
#endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...