제출 #226020

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

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:6:3: error: 'vector' was not declared in this scope
    6 |   vector < char > vc = {'A', 'X', 'B', '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 | using namespace std;
combo.cpp:6:12: error: expected primary-expression before 'char'
    6 |   vector < char > vc = {'A', 'X', 'B', 'Y'};
      |            ^~~~
combo.cpp:10:7: error: 'vc' was not declared in this scope
   10 |       vc.erase(vc.begin());
      |       ^~
combo.cpp:14:7: error: 'vc' was not declared in this scope
   14 |       vc.erase(vc.begin() + 2);
      |       ^~
combo.cpp:20:7: error: 'vc' was not declared in this scope
   20 |       vc.erase(vc.begin() + 1);
      |       ^~
combo.cpp:24:7: error: 'vc' was not declared in this scope
   24 |       vc.erase(vc.begin() + 2);
      |       ^~
combo.cpp:30:14: error: 'vc' was not declared in this scope
   30 |     t += p + vc[0];
      |              ^~
combo.cpp:46:12: error: 'vc' was not declared in this scope
   46 |   t += p + vc[0];
      |            ^~