제출 #236676

#제출 시각아이디문제언어결과실행 시간메모리
236676DS007Jakarta Skyscrapers (APIO15_skyscraper)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 30000; vector<pair<int, int>> adj[N]; int b[N], p[N]; set<int> inv[N]; int n, m; void solveTestCase() { cin >> n >> m; for (int i = 0; i < m; i++) { cin >> b[i] >> p[i]; inv[b[i]].insert(p[i]); } for (int i = 0; i < m; i++) { for (int j = b[i] - p[i], k = 1; j >= 0; j -= p[i], k++) { adj[b[i]].emplace_back(j, k); if (inv[j].count(p[i])) break; } for (int j = b[i] + p[i], k = 1; j < n; j += p[i], k++) { adj[b[i]].emplace_back(j, k); if (inv[j].count(p[i])) break; } } int dist[n]; fill(dist, dist + n, 1e18); dist[b[0]] = 0; priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>()> pq; pq.push({0, b[0]}); set<int> done; while (!pq.empty()) { auto temp = pq.top(); pq.pop(); if (done.count(temp.second)) break; done.insert(temp.second); assert(temp.first == dist[temp.second]); for (auto i : adj[temp.second]) { if (dist[i.first] > temp.first + i.second) { dist[i.first] = temp.first + i.second; pq.push({dist[i.first], i.first}); } } } cout << (dist[b[1]] == 1e18 ? -1 : dist[b[1]]); } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int test = 1; // cin >> test; while (test--) solveTestCase(); }

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

In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from skyscraper.cpp:1:
/usr/include/c++/7/bits/stl_queue.h: In instantiation of 'class std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<void>()>':
skyscraper.cpp:34:73:   required from here
/usr/include/c++/7/bits/stl_queue.h:457:18: error: field 'std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<void>()>::comp' invalidly declared function type
       _Compare   comp;
                  ^~~~
skyscraper.cpp: In function 'void solveTestCase()':
skyscraper.cpp:34:73: error: no matching function for call to 'std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<void>()>::priority_queue()'
     priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>()> pq;
                                                                         ^~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from skyscraper.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:552:2: note: candidate: template<class _InputIterator> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&)
  priority_queue(_InputIterator __first, _InputIterator __last,
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:552:2: note:   template argument deduction/substitution failed:
skyscraper.cpp:34:73: note:   candidate expects 4 arguments, 0 provided
     priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>()> pq;
                                                                         ^~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from skyscraper.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:541:2: note: candidate: template<class _InputIterator> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&)
  priority_queue(_InputIterator __first, _InputIterator __last,
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:541:2: note:   template argument deduction/substitution failed:
skyscraper.cpp:34:73: note:   candidate expects 4 arguments, 0 provided
     priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>()> pq;
                                                                         ^~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from skyscraper.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:509:2: note: candidate: template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(std::priority_queue<_Tp, _Sequence, _Compare>&&, const _Alloc&)
  priority_queue(priority_queue&& __q, const _Alloc& __a)
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:509:2: note:   template argument deduction/substitution failed:
skyscraper.cpp:34:73: note:   candidate expects 2 arguments, 0 provided
     priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>()> pq;
                                                                         ^~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from skyscraper.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:505:2: note: candidate: template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const std::priority_queue<_Tp, _Sequence, _Compare>&, const _Alloc&)
  priority_queue(const priority_queue& __q, const _Alloc& __a)
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:505:2: note:   template argument deduction/substitution failed:
skyscraper.cpp:34:73: note:   candidate expects 2 arguments, 0 provided
     priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>()> pq;
                                                                         ^~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from skyscraper.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:501:2: note: candidate: template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&, const _Alloc&)
  priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a)
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:501:2: note:   template argument deduction/substitution failed:
skyscraper.cpp:34:73: note:   candidate expects 3 arguments, 0 provided
     priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>()> pq;
                                                                         ^~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from skyscraper.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:496:2: note: candidate: template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&, const _Alloc&)
  priority_queue(const _Compare& __x, const _Sequence& __c,
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:496:2: note:   template argument deduction/substitution failed:
skyscraper.cpp:34:73: note:   candidate expects 3 arguments, 0 provided
     priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>()> pq;
                                                                         ^~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from skyscraper.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:492:2: note: candidate: template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Alloc&)
  priority_queue(const _Compare& __x, const _Alloc& __a)
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:492:2: note:   template argument deduction/substitution failed:
skyscraper.cpp:34:73: note:   candidate expects 2 arguments, 0 provided
     priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>()> pq;
                                                                         ^~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from skyscraper.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:488:2: note: candidate: template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Alloc&)
  priority_queue(const _Alloc& __a)
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:488:2: note:   template argument deduction/substitution failed:
skyscraper.cpp:34:73: note:   candidate expects 1 argument, 0 provided
     priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>()> pq;
                                                                         ^~
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from skyscraper.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:482:7: note: candidate: std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = std::greater<void>()]
       priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence())
       ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:482:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/7/bits/stl_queue.h:477:7: note: candidate: std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = std::greater<void>()]
       priority_queue(const _Compare& __x, const _Sequence& __s)
       ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:477:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/7/bits/stl_queue.h:473:2: note: candidate: template<class _Seq, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue()
  priority_queue()
  ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:473:2: note:   template argument deduction/substitution failed:
/usr/include/c++/7/bits/stl_queue.h:470:43: error: no type named 'type' in 'struct std::enable_if<false, void>'
       template<typename _Seq = _Sequence, typename _Requires = typename
                                           ^~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:423:11: note: candidate: std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<void>()>::priority_queue(const std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<void>()>&)
     class priority_queue
           ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:423:11: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/7/bits/stl_queue.h:423:11: note: candidate: std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<void>()>::priority_queue(std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<void>()>&&)
/usr/include/c++/7/bits/stl_queue.h:423:11: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from skyscraper.cpp:1:
/usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Value = std::pair<long long int, long long int>; _Compare = std::greater<void> (*)()]':
/usr/include/c++/7/bits/stl_heap.h:133:48:   required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Distance = long int; _Tp = std::pair<long long int, long long int>; _Compare = __gnu_cxx::__ops::_Iter_comp_val<std::greater<void> (*)()>]'
/usr/include/c++/7/bits/stl_heap.h:207:23:   required from 'void std::push_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Compare = std::greater<void> (*)()]'
/usr/include/c++/7/bits/stl_queue.h:606:16:   required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = std::greater<void>(); std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<long long int, long long int>]'
skyscraper.cpp:35:22:   required from here
/usr/include/c++/7/bits/predefined_ops.h:177:11: error: too many arguments to function
  { return bool(_M_comp(*__it, __val)); }
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/predefined_ops.h:177:11: error: invalid cast from type 'std::greater<void>' to type 'bool'
/usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Iterator2 = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Compare = std::greater<void> (*)()]':
/usr/include/c++/7/bits/stl_heap.h:222:14:   required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Distance = long int; _Tp = std::pair<long long int, long long int>; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<std::greater<void> (*)()>]'
/usr/include/c++/7/bits/stl_heap.h:253:25:   required from 'void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<std::greater<void> (*)()>]'
/usr/include/c++/7/bits/stl_heap.h:320:19:   required from 'void std::pop_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Compare = std::greater<void> (*)()]'
/usr/include/c++/7/bits/stl_queue.h:633:15:   required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::pop() [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = std::greater<void>()]'
skyscraper.cpp:40:16:   required from here
/usr/include/c++/7/bits/predefined_ops.h:143:18: error: too many arguments to function
         { return bool(_M_comp(*__it1, *__it2)); }
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/predefined_ops.h:143:18: error: invalid cast from type 'std::greater<void>' to type 'bool'