제출 #599196

#제출 시각아이디문제언어결과실행 시간메모리
599196pakhomovee커다란 상품 (IOI17_prize)C++17
컴파일 에러
0 ms0 KiB
#include "prize.h" #include <vector> #include <map> #include <cassert> int find_best(int n) { int pr = 0; std::map<int, int> d; int Q = 1; std::vector<int> q = ask(0); map<int, vector<int>> res; res[0] = q; int lt = q[0]; int rt = q[1]; int sm = lt + rt; if (sm == 0) { return 0; } while (pr != n) { int l = pr, r = n; while (l + 1 < r) { int m = (l + r) / 2; int have = 0; std::vector<int> q; if (!res.count(m)) { q = ask(m); res[m] = q; } else { q = res[m]; } res[m] = q; ++Q; int lt = q[0]; int rt = q[1]; for (auto [x, y] : d) { if (lt + rt > x) { have += y; } } if (lt - have) { r = m; } else { l = m; } } std::vector<int> arr if (!res.count(l)) { arr = ask(l); res[l] = arr; } else { arr = res[l]; } ++Q; if (arr[0] == arr[1] && arr[0] == 0) { return l; } ++d[arr[0] + arr[1]]; pr = l + 1; assert(arr[1] > 0); } return -1; }

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:11:7: error: 'map' was not declared in this scope
   11 |       map<int, vector<int>> res;
      |       ^~~
prize.cpp:11:7: note: suggested alternatives:
In file included from /usr/include/c++/10/map:61,
                 from prize.cpp:3:
/usr/include/c++/10/bits/stl_map.h:100:11: note:   'std::map'
  100 |     class map
      |           ^~~
In file included from prize.cpp:3:
/usr/include/c++/10/map:78:13: note:   'std::pmr::map'
   78 |       using map
      |             ^~~
prize.cpp:11:11: error: expected primary-expression before 'int'
   11 |       map<int, vector<int>> res;
      |           ^~~
prize.cpp:12:7: error: 'res' was not declared in this scope
   12 |       res[0] = q;
      |       ^~~
prize.cpp:47:11: error: expected initializer before 'if'
   47 |           if (!res.count(l)) {
      |           ^~
prize.cpp:50:13: error: 'else' without a previous 'if'
   50 |           } else {
      |             ^~~~
prize.cpp:51:15: error: 'arr' was not declared in this scope
   51 |               arr = res[l];
      |               ^~~
prize.cpp:54:13: error: 'arr' was not declared in this scope
   54 |         if (arr[0] == arr[1] && arr[0] == 0) {
      |             ^~~
prize.cpp:57:13: error: 'arr' was not declared in this scope
   57 |         ++d[arr[0] + arr[1]];
      |             ^~~