제출 #377282

#제출 시각아이디문제언어결과실행 시간메모리
377282gustason로봇 (IOI13_robots)C++14
컴파일 에러
0 ms0 KiB
#include "robots.h" #include<bits/stdc++.h> const int INF = 1e9 + 5; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { sort(X, X+A); sort(Y, Y+B); vector<pair<int, int>> a(T); for(int i = 0; i < n; i++) { a[i] = {W[i], S[i]}; } sort(a.begin(), a.end()); int l = 0, r = INF, ans = 0; while(l <= r) { int mid = (l + r) / 2; priority_queue<int> q; int idx = 0; for(int i = 0; i < A; i++) { while(idx < T && X[i] > v[idx].first) { q.push(v[idx].second); idx++; } for(int j = 0; j < mid && !q.empty(); j++) { q.pop(); } } while(idx < T) { q.push(v[idx].second); idx++; } for(int i = B-1; i >= 0; i--) { for(int j = 0; j < mid && !q.empty(); j++) { if (q.top() < Y[i]) { q.pop(); } else { break; } } } if (q.empty()) { ans = mid; r = mid - 1; } else { l = mid + 1; } } if (ans == INF) return -1; return ans; }

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:5:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
    5 |     sort(X, X+A);
      |     ^~~~
      |     std::sort
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from robots.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:4887:5: note: 'std::sort' declared here
 4887 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
robots.cpp:7:5: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
    7 |     vector<pair<int, int>> a(T);
      |     ^~~~~~
      |     std::vector
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 from robots.cpp:2:
/usr/include/c++/9/bits/stl_vector.h:386:11: note: 'std::vector' declared here
  386 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
robots.cpp:7:12: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    7 |     vector<pair<int, int>> a(T);
      |            ^~~~
      |            std::pair
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from robots.cpp:2:
/usr/include/c++/9/bits/stl_pair.h:208:12: note: 'std::pair' declared here
  208 |     struct pair
      |            ^~~~
robots.cpp:7:17: error: expected primary-expression before 'int'
    7 |     vector<pair<int, int>> a(T);
      |                 ^~~
robots.cpp:8:24: error: 'n' was not declared in this scope
    8 |     for(int i = 0; i < n; i++) {
      |                        ^
robots.cpp:9:9: error: 'a' was not declared in this scope
    9 |         a[i] = {W[i], S[i]};
      |         ^
robots.cpp:11:10: error: 'a' was not declared in this scope
   11 |     sort(a.begin(), a.end());
      |          ^
robots.cpp:16:9: error: 'priority_queue' was not declared in this scope; did you mean 'std::priority_queue'?
   16 |         priority_queue<int> q;
      |         ^~~~~~~~~~~~~~
      |         std::priority_queue
In file included from /usr/include/c++/9/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 from robots.cpp:2:
/usr/include/c++/9/bits/stl_queue.h:443:11: note: 'std::priority_queue' declared here
  443 |     class priority_queue
      |           ^~~~~~~~~~~~~~
robots.cpp:16:24: error: expected primary-expression before 'int'
   16 |         priority_queue<int> q;
      |                        ^~~
robots.cpp:20:37: error: 'v' was not declared in this scope
   20 |             while(idx < T && X[i] > v[idx].first) {
      |                                     ^
robots.cpp:21:17: error: 'q' was not declared in this scope
   21 |                 q.push(v[idx].second);
      |                 ^
robots.cpp:24:40: error: 'q' was not declared in this scope
   24 |             for(int j = 0; j < mid && !q.empty(); j++) {
      |                                        ^
robots.cpp:29:13: error: 'q' was not declared in this scope
   29 |             q.push(v[idx].second);
      |             ^
robots.cpp:29:20: error: 'v' was not declared in this scope
   29 |             q.push(v[idx].second);
      |                    ^
robots.cpp:33:40: error: 'q' was not declared in this scope
   33 |             for(int j = 0; j < mid && !q.empty(); j++) {
      |                                        ^
robots.cpp:42:13: error: 'q' was not declared in this scope
   42 |         if (q.empty()) {
      |             ^