제출 #393721

#제출 시각아이디문제언어결과실행 시간메모리
393721ruadhanCombo (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;
#define sz(x) (int)x.size()
// string S;
// int N;

// int press(string p)
// {
//     // cout << "pressing " << p << '\n';
//     if ((int)p.length() > N * 4)
//         return -1;
//     int ret = 0;
//     int counter = 0;
//     int i = 0;
//     int j = 0;
//     while (i < (int)p.size())
//     {
//         // cout << "i = " << i << '\n';
//         while (i < (int)p.size() && j < (int)S.size() && p.at(i) == S.at(j))
//         {
//             i++, j++, counter++;
//         }
//         ret = max(ret, counter);
//         j = 0, i++;
//         counter = 0;
//     }
//     return ret;
// }

string guess_sequence(int N)
{
    vector<char> chars = {'A', 'B', 'X', 'Y'};
    string s = "";
    array<char, 3> otherChars;
    if (press("AB"))
    {
        if (press("A"))
        {
            s += "A";
            otherChars = {'B', 'X', 'Y'};
        }
        else
        {
            s += "B";
            otherChars = {'A', 'X', 'Y'};
        }
    }
    else
    {
        if (press("X"))
        {
            s += "X";
            otherChars = {'A', 'B', 'Y'};
        }
        else
        {
            s += "Y";
            otherChars = {'A', 'B', 'X'};
        }
    }
    for (int i = 1; i < N - 1; i++)
    {
        string combo = s + otherChars[0] + s + otherChars[1] + otherChars[0] + s + otherChars[1] + otherChars[1] + s + otherChars[1] + otherChars[2];
        int start = sz(s);
        int ret = press(combo);
        if (start + 2 == ret)
            s += otherChars[1];
        else if (start + 1 == ret)
            s += otherChars[0];
        else
            s += otherChars[2];
    }
    if (press(s + "A" + s + "B") > sz(s))
    {
        if (press(s + "A") > sz(s))
        {
            s += "A";
        }
        else
        {
            s += "B";
        }
    }
    else
    {
        if (press(s + "X") > sz(s))
        {
            s += "X";
        }
        else
        {
            s += "Y";
        }
    }
    return s;
}

// int main()
// {
//     S = "ABXYY";
//     N = S.length();

//     cout << guess_sequence(N) << '\n';

//     return 0;
// }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:36:9: error: 'press' was not declared in this scope
   36 |     if (press("AB"))
      |         ^~~~~
combo.cpp:66:19: error: 'press' was not declared in this scope
   66 |         int ret = press(combo);
      |                   ^~~~~
combo.cpp:74:9: error: 'press' was not declared in this scope
   74 |     if (press(s + "A" + s + "B") > sz(s))
      |         ^~~~~