제출 #861368

#제출 시각아이디문제언어결과실행 시간메모리
861368imarn콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
int press(std::string p);
std::string guess_sequence(int N){
    std::string ans="";
    char s[4];
    if(press("A")==1)ans="A",s[0]='A',s[1]='B',s[2]='X',s[3]='Y';
    else if(press("B")==1)ans="B",s[0]='B',s[1]='A',s[2]='X',s[3]='Y';
    else if(press("X")==1)ans="X",s[0]='X',s[1]='B',s[2]='A',s[3]='Y';
    else ans="Y",s[0]='Y',s[1]='B',s[2]='X',s[3]='A';
    for(int i=2;i<=N-1;i++){
        std::string now1 = ans;now1+=s[1];
        std::string now2 = ans;now2+=s[2];now2+=s[1];
        std::string now3 = ans;now3+=s[2];now3+=s[2];
        std::string now4 = ans;now4+=s[2];now4+=s[3];
        std::string tt = now1+now2+now3+now4;
        int x = press(tt);
        if(x==i-1)ans = ans+s[3];
        else if(x==i)ans = ans+s[1];
        else if(x==i+1)ans = ans+s[2];
    }if(press(ans+s[1])==N)return ans+s[1];
    if(press(ans+s[2])==N)return ans+s[2];
    else return ans+s[3];
}

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

combo.cpp:1:16: error: 'string' is not a member of 'std'
    1 | int press(std::string p);
      |                ^~~~~~
combo.cpp:1:1: note: 'std::string' is defined in header '<string>'; did you forget to '#include <string>'?
  +++ |+#include <string>
    1 | int press(std::string p);
combo.cpp:2:6: error: 'string' in namespace 'std' does not name a type
    2 | std::string guess_sequence(int N){
      |      ^~~~~~
combo.cpp:2:1: note: 'std::string' is defined in header '<string>'; did you forget to '#include <string>'?
    2 | std::string guess_sequence(int N){
      | ^~~