제출 #1006751

#제출 시각아이디문제언어결과실행 시간메모리
1006751makanhulia콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include "combo.h" using namespace std; string guess_sequence(int N) { string S = ""; char a; string p = "AB"; int coins = press(p); if(coins){ p = "A"; coins = press(p); if(coins) a = 'A'; else a = 'B'; } else{ p = "X"; coins = press(p); if(coins) a = 'X'; else a = 'Y'; } S += a; vector <char> v; if(a != 'A') v += 'A'; if(a != 'B') v += 'B'; if(a != 'X') v += 'X'; if(a != 'Y') v += 'Y'; for(int i = 0; i < N-2; i++){ int t = 0; p = ""; for(int j = 0; j < 3; j++){ if(j == 0){ for(auto y : v) p += S + v[j] + y; } if(j == 1) p += S + v[j]; } coins = press(p); if(coins == 2) S += v[0]; else if(coins == 1) S += v[1]; else S += v[2]; } coins = press(p); p = S + v[0] + S + v[1]; if(coins == N){ p = S + v[0] coins = press(p); if(coins == N) S += v[0]; else S += v[1]; } else S += v[2]; return S; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:22:3: error: 'vector' was not declared in this scope
   22 |   vector <char> v;
      |   ^~~~~~
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:22:11: error: expected primary-expression before 'char'
   22 |   vector <char> v;
      |           ^~~~
combo.cpp:23:16: error: 'v' was not declared in this scope
   23 |   if(a != 'A') v += 'A';
      |                ^
combo.cpp:24:16: error: 'v' was not declared in this scope
   24 |   if(a != 'B') v += 'B';
      |                ^
combo.cpp:25:16: error: 'v' was not declared in this scope
   25 |   if(a != 'X') v += 'X';
      |                ^
combo.cpp:26:16: error: 'v' was not declared in this scope
   26 |   if(a != 'Y') v += 'Y';
      |                ^
combo.cpp:32:22: error: 'v' was not declared in this scope
   32 |         for(auto y : v) p += S + v[j] + y;
      |                      ^
combo.cpp:34:27: error: 'v' was not declared in this scope
   34 |       if(j == 1) p += S + v[j];
      |                           ^
combo.cpp:37:25: error: 'v' was not declared in this scope
   37 |     if(coins == 2) S += v[0];
      |                         ^
combo.cpp:38:30: error: 'v' was not declared in this scope
   38 |     else if(coins == 1) S += v[1];
      |                              ^
combo.cpp:39:15: error: 'v' was not declared in this scope
   39 |     else S += v[2];
      |               ^
combo.cpp:28:9: warning: unused variable 't' [-Wunused-variable]
   28 |     int t = 0;
      |         ^
combo.cpp:42:11: error: 'v' was not declared in this scope
   42 |   p = S + v[0] + S + v[1];
      |           ^