제출 #1227734

#제출 시각아이디문제언어결과실행 시간메모리
1227734Tesla89콤보 (IOI18_combo)C++20
컴파일 에러
0 ms0 KiB
#include "combo.h" using namespace std; string guess_sequence(int N) { string res=""; vector<char> ch; if(press("AB")>0){ if(press("A")==1){ res="A"; ch = {'B','X','Y'}; } else{ res="B"; ch = {'A','X','Y'}; } } else if(press("X")==1){ res="X"; ch = {'A','B','Y'}; } else{ res="Y"; ch = {'A','B','X'}; } string query=""; int last=1; for(int i=1;i<N-1;i++){ for(int j=0;j<3;j++){ query+=res+ch[2]+ch[j]; } query+=res+ch[1]; int response=press(query); res+=ch[response-last]; last=response; query=""; } query=res+ch[0]+res+ch[1]; if(press(query)==last)res+=ch[2]; else if(press(res+ch[0])==last)res+=ch[1]; else res+=ch[0]; return res; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:7:5: error: 'vector' was not declared in this scope
    7 |     vector<char> 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:7:12: error: expected primary-expression before 'char'
    7 |     vector<char> ch;
      |            ^~~~
combo.cpp:11:13: error: 'ch' was not declared in this scope
   11 |             ch = {'B','X','Y'};
      |             ^~
combo.cpp:15:13: error: 'ch' was not declared in this scope
   15 |             ch = {'A','X','Y'};
      |             ^~
combo.cpp:20:9: error: 'ch' was not declared in this scope
   20 |         ch = {'A','B','Y'};
      |         ^~
combo.cpp:24:9: error: 'ch' was not declared in this scope
   24 |         ch = {'A','B','X'};
      |         ^~
combo.cpp:30:24: error: 'ch' was not declared in this scope
   30 |             query+=res+ch[2]+ch[j];
      |                        ^~
combo.cpp:32:20: error: 'ch' was not declared in this scope
   32 |         query+=res+ch[1];
      |                    ^~
combo.cpp:38:15: error: 'ch' was not declared in this scope
   38 |     query=res+ch[0]+res+ch[1];
      |               ^~