제출 #963928

#제출 시각아이디문제언어결과실행 시간메모리
963928Mardonbekhazratov콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include "combo.h" using namespace std; string guess_sequence(int N) { string p = ""; if(press("AB")){ if(press("A")) p+="A"; else p+="B"; } else{ if(press("X")) p+="X"; else p+="Y"; } vector<char>d={"A","B","X","Y"}; for(int i=0;i<4;i++){ if(d[i]==p[0]){ d.erase(d.begin()+i); } } for(int i=2;i<n;i++){ string f1=p+d[0]+d[0]; string f2=p+d[0]+d[1]; string f3=p+d[0]+d[2]; string f4=p+d[1]; int x=press(f1+f2+f3+f4); if(x==i-1){ p+=d[2]; } else if(x==i){ p+=d[1]; } else{ p+=d[0]; } } for(int i=0;i<2;i++){ string f=p+d[i]; if(press(f)==n){ p+=d[i]; break; } if(i==1) p+=d[2]; } return p; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:15:3: error: 'vector' was not declared in this scope
   15 |   vector<char>d={"A","B","X","Y"};
      |   ^~~~~~
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:15:10: error: expected primary-expression before 'char'
   15 |   vector<char>d={"A","B","X","Y"};
      |          ^~~~
combo.cpp:17:8: error: 'd' was not declared in this scope
   17 |     if(d[i]==p[0]){
      |        ^
combo.cpp:21:17: error: 'n' was not declared in this scope
   21 |   for(int i=2;i<n;i++){
      |                 ^
combo.cpp:22:17: error: 'd' was not declared in this scope
   22 |     string f1=p+d[0]+d[0];
      |                 ^
combo.cpp:38:16: error: 'd' was not declared in this scope
   38 |     string f=p+d[i];
      |                ^
combo.cpp:39:18: error: 'n' was not declared in this scope
   39 |     if(press(f)==n){
      |                  ^