답안 #82786

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
82786 2018-11-01T16:31:37 Z 314rate 콤보 (IOI18_combo) C++14
컴파일 오류
0 ms 0 KB
#include <combo.h>

using namespace std;
string guess_sequence (int n)
{
    string ans;
    if (press ("AB"))
    {
        if (press ("A"))
        {
            ans = "A";
        }
        else
        {
            ans = "B";
        }
    }
    else
    {
        if (press ("X"))
        {
            ans = "X";
        }
        else
        {
            ans = "Y";
        }
    }
    vector<string>ch;
    if (ans[0] != 'A') ch.push_back ("A");
    if (ans[0] != 'B') ch.push_back ("B");
    if (ans[0] != 'X') ch.push_back ("X");
    if (ans[0] != 'Y') ch.push_back ("Y");
    for (int i = 1; i <= n - 2; i++)
    {
        string ask;
        ask += ans + (ch[2] + ch[0]);
        ask += ans + (ch[2] + ch[1]);
        ask += ans + (ch[2] + ch[2]);
        ask += ans + (ch[1]);
        int value = press (ask) - i;
        ans += ch[value];
    }
    if (press (ans + ch[0]) == n)
    {
        ans += ch[0];
    }
    else
    {
        if (press (ans + ch[1]) == n)
        {
            ans += ch[1];
        }
        else
        {
            ans += ch[2];
        }
    }
    return ans;
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:29:5: error: 'vector' was not declared in this scope
   29 |     vector<string>ch;
      |     ^~~~~~
combo.cpp:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    1 | #include <combo.h>
  +++ |+#include <vector>
    2 | 
combo.cpp:29:18: error: expected primary-expression before '>' token
   29 |     vector<string>ch;
      |                  ^
combo.cpp:29:19: error: 'ch' was not declared in this scope
   29 |     vector<string>ch;
      |                   ^~