제출 #1259834

#제출 시각아이디문제언어결과실행 시간메모리
1259834sokratisi콤보 (IOI18_combo)C++20
컴파일 에러
0 ms0 KiB
#include "combo.h" #include <string> #include <set> using namespace std; int coins; string use; //int press(string p); char find_first() { use = "AB"; coins = press(use); if (coins) { use = "A"; coins = press(use); if (coins) return 'A'; else return 'B'; } use = "X"; coins = press(use); if (coins) return 'X'; else return 'Y'; } string guess_sequence(int n) { char c = find_first(); set<char> s = {'A', 'B', 'X', 'Y'}; s.erase(c); vector<char> chrs; for (auto u: s) chrs.push_back(u); string p = ""; p += c; for (int i = 2; i <= n - 1; i++) { use = p + chrs[0] + chrs[0] + p + chrs[0] + chrs[1] + p + chrs[0] + chrs[2] + p + chrs[1]; int coins = press(use); if (coins == i + 1) p += chrs[0]; else if (coins == i) p += chrs[1]; else p += chrs[2]; } use = p + chrs[0]; coins = press(use); if (coins == n) return use; use = p + chrs[1]; coins = press(use); if (coins == n) return use; return (p + chrs[2]); }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:31:3: error: 'vector' was not declared in this scope
   31 |   vector<char> chrs;
      |   ^~~~~~
combo.cpp:4:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    3 | #include <set>
  +++ |+#include <vector>
    4 | 
combo.cpp:31:10: error: expected primary-expression before 'char'
   31 |   vector<char> chrs;
      |          ^~~~
combo.cpp:32:19: error: 'chrs' was not declared in this scope
   32 |   for (auto u: s) chrs.push_back(u);
      |                   ^~~~
combo.cpp:37:15: error: 'chrs' was not declared in this scope
   37 |     use = p + chrs[0] + chrs[0] + p + chrs[0] + chrs[1] + p + chrs[0] + chrs[2] + p + chrs[1];
      |               ^~~~
combo.cpp:43:13: error: 'chrs' was not declared in this scope
   43 |   use = p + chrs[0];
      |             ^~~~