제출 #1193761

#제출 시각아이디문제언어결과실행 시간메모리
1193761emad234Jakarta Skyscrapers (APIO15_skyscraper)C++20
컴파일 에러
0 ms0 KiB
#pragma GCC optimize("Ofast,O3,unroll-loops") #pragma GCC target("avx,avx2") #include <bits/stdc++.h> #define ll long long #define F first #define S second #define pii pair<int, int> using namespace std; vector<pii>v; int pos[2]; vector<int>dist; bool operator<(pair<int,int>a,pair<int,int>b){ return a.S > b.S; } int n,m; int conv(int q,int p){ return p * n + q; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >>n>>m; int buck = 175; dist.resize(n * buck + 1); v.resize(n * buck + 1); for(int i = 0;i < m;i++){ int q,p; cin >>q>>p; if(i < 2) pos[i] = q; if(p <= buck){ v[conv(q,0)].push_back({conv(q,p),0}); }else{ int cnt = 1; for(int j = q - p;j >= 0;j -= p){ v[conv(q,0)].push_back({conv(j,0),cnt}); cnt++; } cnt = 1; for(int j = q + p;j < n;j += p){ v[conv(q,0)].push_back({conv(j,0),cnt}); cnt++; } } } for(int i = 0;i < n;i++){ for(int p = 0;p <= buck;p++){ dist[conv(i,p)] = 1e9; } } dist[pos[0]] = 0; priority_queue<pair<int,int>>q; q.push({pos[0],0}); while(q.size()){ auto u = q.top(); // cout<<u.F<<' '<<u.S<<'\n'; q.pop(); if(dist[u.F] < u.S) continue; for(auto x : v[u.F]){ if(dist[x.F] > u.S + x.S){ dist[x.F] = u.S + x.S; q.push({x.F,dist[x.F]}); } } pii x; if(u.F >= n){ x = {u.F + u.F / n,1}; if(x.F / n == u.F / n && dist[x.F] > u.S + x.S){ dist[x.F] = u.S + x.S; q.push({x.F,dist[x.F]}); } x = {u.F - u.F / n,1}; if(x.F / n == u.F / n && dist[x.F] > u.S + x.S){ dist[x.F] = u.S + x.S; q.push({x.F,dist[x.F]}); } x = {u.F % n,0}; if(dist[x.F] > u.S + x.S){ dist[x.F] = u.S + x.S; q.push({x.F,dist[x.F]}); } } } cout<<(dist[pos[1]] == 1e9 ? -1 : dist[pos[1]]); }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:32:20: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'push_back'
   32 |       v[conv(q,0)].push_back({conv(q,p),0});
      |                    ^~~~~~~~~
skyscraper.cpp:36:22: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'push_back'
   36 |         v[conv(q,0)].push_back({conv(j,0),cnt});
      |                      ^~~~~~~~~
skyscraper.cpp:41:22: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'push_back'
   41 |         v[conv(q,0)].push_back({conv(j,0),cnt});
      |                      ^~~~~~~~~
skyscraper.cpp:59:23: error: no matching function for call to 'begin(std::pair<int, int>&)'
   59 |     for(auto x : v[u.F]){
      |                       ^
In file included from /usr/include/c++/11/bits/algorithmfwd.h:39,
                 from /usr/include/c++/11/bits/stl_algo.h:60,
                 from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from skyscraper.cpp:3:
/usr/include/c++/11/initializer_list:90:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)'
   90 |     begin(initializer_list<_Tp> __ils) noexcept
      |     ^~~~~
/usr/include/c++/11/initializer_list:90:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:59:23: note:   'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
   59 |     for(auto x : v[u.F]){
      |                       ^
In file included from /usr/include/c++/11/string:54,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from skyscraper.cpp:3:
/usr/include/c++/11/bits/range_access.h:51:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)'
   51 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/11/bits/range_access.h:51:5: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&) [with _Container = std::pair<int, int>]':
skyscraper.cpp:59:23:   required from here
/usr/include/c++/11/bits/range_access.h:51:50: error: 'struct std::pair<int, int>' has no member named 'begin'
   51 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |                                           ~~~~~~~^~~~~
/usr/include/c++/11/bits/range_access.h:61:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)'
   61 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/11/bits/range_access.h:61:5: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&) [with _Container = std::pair<int, int>]':
skyscraper.cpp:59:23:   required from here
/usr/include/c++/11/bits/range_access.h:61:56: error: 'const struct std::pair<int, int>' has no member named 'begin'
   61 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |                                                 ~~~~~~~^~~~~
/usr/include/c++/11/bits/range_access.h:90:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])'
   90 |     begin(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~~~
/usr/include/c++/11/bits/range_access.h:90:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:59:23: note:   mismatched types '_Tp [_Nm]' and 'std::pair<int, int>'
   59 |     for(auto x : v[u.F]){
      |                       ^
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from skyscraper.cpp:3:
/usr/include/c++/11/valarray:1217:5: note: candidate: 'template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&)'
 1217 |     begin(valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/11/valarray:1217:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:59:23: note:   'std::pair<int, int>' is not derived from 'std::valarray<_Tp>'
   59 |     for(auto x : v[u.F]){
      |                       ^
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from skyscraper.cpp:3:
/usr/include/c++/11/valarray:1228:5: note: candidate: 'template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&)'
 1228 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/11/valarray:1228:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:59:23: note:   'std::pair<int, int>' is not derived from 'const std::valarray<_Tp>'
   59 |     for(auto x : v[u.F]){
      |                       ^
skyscraper.cpp:59:23: error: no matching function for call to 'end(std::pair<int, int>&)'
In file included from /usr/include/c++/11/bits/algorithmfwd.h:39,
                 from /usr/include/c++/11/bits/stl_algo.h:60,
                 from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from skyscraper.cpp:3:
/usr/include/c++/11/initializer_list:101:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
  101 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
/usr/include/c++/11/initializer_list:101:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:59:23: note:   'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
   59 |     for(auto x : v[u.F]){
      |                       ^
In file included from /usr/include/c++/11/string:54,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from skyscraper.cpp:3:
/usr/include/c++/11/bits/range_access.h:71:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   71 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/11/bits/range_access.h:71:5: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&) [with _Container = std::pair<int, int>]':
skyscraper.cpp:59:23:   required from here
/usr/include/c++/11/bits/range_access.h:71:48: error: 'struct std::pair<int, int>' has no member named 'end'
   71 |     end(_Container& __cont) -> decltype(__cont.end())
      |                                         ~~~~~~~^~~
/usr/include/c++/11/bits/range_access.h:81:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   81 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/11/bits/range_access.h:81:5: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&) [with _Container = std::pair<int, int>]':
skyscraper.cpp:59:23:   required from here
/usr/include/c++/11/bits/range_access.h:81:54: error: 'const struct std::pair<int, int>' has no member named 'end'
   81 |     end(const _Container& __cont) -> decltype(__cont.end())
      |                                               ~~~~~~~^~~
/usr/include/c++/11/bits/range_access.h:100:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  100 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/11/bits/range_access.h:100:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:59:23: note:   mismatched types '_Tp [_Nm]' and 'std::pair<int, int>'
   59 |     for(auto x : v[u.F]){
      |                       ^
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from skyscraper.cpp:3:
/usr/include/c++/11/valarray:1239:5: note: candidate: 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
 1239 |     end(valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/11/valarray:1239:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:59:23: note:   'std::pair<int, int>' is not derived from 'std::valarray<_Tp>'
   59 |     for(auto x : v[u.F]){
      |                       ^
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from skyscraper.cpp:3:
/usr/include/c++/11/valarray:1255:5: note: candidate: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
 1255 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/11/valarray:1255:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:59:23: note:   'std::pair<int, int>' is not derived from 'const std::valarray<_Tp>'
   59 |     for(auto x : v[u.F]){
      |                       ^
skyscraper.cpp:62:15: error: no matching function for call to 'std::priority_queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)'
   62 |         q.push({x.F,dist[x.F]});
      |         ~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:86,
                 from skyscraper.cpp:3:
/usr/include/c++/11/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::less<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::less<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~