제출 #303830

#제출 시각아이디문제언어결과실행 시간메모리
303830Gilgamesh콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include "combo.h"

std::string guess_sequence(int N) {
    std::string ans = "";
    for(int i = 0; i < N; ++i){
        string ab = ans + "A";
        for(int j = 0; j < N; ++j){
            ab += "A";
        }
        ab += ans + "B";
        int curab = press(ab);
        if(curab == i + 1){
            int a = press(ans + "A");
            if(a == i + 1){
                ans += "A";
            }
            else ans += "B";
        } else{
            int x = press(ans + "X");
            if(x == i + 1){
                ans += "X";
            }
            else ans += "Y";
        }
    }
    return ans;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:6:9: error: 'string' was not declared in this scope
    6 |         string ab = ans + "A";
      |         ^~~~~~
combo.cpp:6:9: note: suggested alternatives:
In file included from /usr/include/c++/10/string:39,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/bits/stringfwd.h:79:33: note:   'std::string'
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/string:67:11: note:   'std::pmr::string'
   67 |     using string    = basic_string<char>;
      |           ^~~~~~
combo.cpp:8:13: error: 'ab' was not declared in this scope; did you mean 'abs'?
    8 |             ab += "A";
      |             ^~
      |             abs
combo.cpp:10:9: error: 'ab' was not declared in this scope; did you mean 'abs'?
   10 |         ab += ans + "B";
      |         ^~
      |         abs