제출 #1323965

#제출 시각아이디문제언어결과실행 시간메모리
1323965QuocSensei콤보 (IOI18_combo)C++20
컴파일 에러
0 ms0 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;

#ifdef LOCAL
int press(string p)
{
    int res = 0;
    if (is_gen)
    {
        cout << p << endl;
        for (int i = ans.size(); i >= 1; i--)
        {
            for (int j = 0; j + i - 1 < p.size(); j++)
            {
                if (p.substr(j, i) == ans.substr(0, i))
                {
                    res = i;
                    break;
                }
            }
            if (res)
                break;
        }
        cout << res << endl;
        return res;
    }
    else
    {
        cout << "? " << p << endl;
        cin >> res;
    }
    return res;
}
#endif
string guess_string(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_string(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

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp: In function 'std::string guess_string(int)':
combo.cpp:62:9: error: 'press' was not declared in this scope
   62 |     if (press("AB"))
      |         ^~~~~
combo.cpp:77:21: error: 'press' was not declared in this scope
   77 |         int state = press(ans + ch[1] + ch[1] + ans + ch[1] + ch[2] + ans + ch[1] + ch[3] + ans + ch[2]);
      |                     ^~~~~
combo.cpp:85:9: error: 'press' was not declared in this scope
   85 |     if (press(ans + ch[1]) == N)
      |         ^~~~~