제출 #259236

#제출 시각아이디문제언어결과실행 시간메모리
259236shayan_pJakarta Skyscrapers (APIO15_skyscraper)C++14
컴파일 에러
0 ms0 KiB
// And you curse yourself for things you never done #include<bits/stdc++.h> #define F first #define S second #define PB push_back #define sz(s) int((s).size()) #define bit(n,k) (((n)>>(k))&1) using namespace std; typedef long long ll; typedef pair<int,int> pii; const int maxn = 3e4 + 10; set<int> st[maxn]; set<int> calced[maxn]; int dis[maxn]; bool done[maxn]; pii p[maxn]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(); int n, m; cin >> n >> m; for(int i = 0; i < m; i++){ cin >> p[i].F >> p[i].S; st[p[i].F].insert(p[i].S); } fill(dis, dis + maxn, -1); dequeue< pair<pii, int> > q; q.push({p[0], 0}); while(sz(q)){ int pos = q.front().F.F, p = q.front().F.S, d = q.front().S; q.pop_front(); if(calced[pos].count(p)) continue; calced[pos].insert(p); if(done[pos] == 0){ dis[pos] = d; for(int x : st[pos]) q.push_front({ {pos, x}, d }); } done[pos] = 1; if(pos >= p) q.push_front({ {pos - p, p}, d + 1 }); if(pos + p < n) q.push_front({ {pos + p, p}, d + 1 }); } return cout << dis[p[1].F] << endl, 0; }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:35:5: error: 'dequeue' was not declared in this scope
     dequeue< pair<pii, int> > q;
     ^~~~~~~
skyscraper.cpp:35:5: note: suggested alternative: 'sigqueue'
     dequeue< pair<pii, int> > q;
     ^~~~~~~
     sigqueue
skyscraper.cpp:35:29: error: expected primary-expression before '>' token
     dequeue< pair<pii, int> > q;
                             ^
skyscraper.cpp:35:31: error: 'q' was not declared in this scope
     dequeue< pair<pii, int> > q;
                               ^
skyscraper.cpp:40:24: error: no matching function for call to 'std::set<int>::count(pii [30010])'
  if(calced[pos].count(p))
                        ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from skyscraper.cpp:3:
/usr/include/c++/7/bits/stl_set.h:738:7: note: candidate: std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::set<_Key, _Compare, _Alloc>::key_type = int] <near match>
       count(const key_type& __x) const
       ^~~~~
/usr/include/c++/7/bits/stl_set.h:738:7: note:   conversion of argument 1 would be ill-formed:
skyscraper.cpp:40:24: error: invalid conversion from 'pii* {aka std::pair<int, int>*}' to 'std::set<int>::key_type {aka int}' [-fpermissive]
  if(calced[pos].count(p))
                        ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from skyscraper.cpp:3:
/usr/include/c++/7/bits/stl_set.h:744:2: note: candidate: template<class _Kt> decltype (((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::set<_Key, _Compare, _Alloc>::count(const _Kt&) const [with _Kt = _Kt; _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]
  count(const _Kt& __x) const
  ^~~~~
/usr/include/c++/7/bits/stl_set.h:744:2: note:   template argument deduction/substitution failed:
/usr/include/c++/7/bits/stl_set.h: In substitution of 'template<class _Kt> decltype (((const std::set<int>*)this)->std::set<int>::_M_t.std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_count_tr<_Kt, _Req>(__x)) std::set<int>::count<_Kt>(const _Kt&) const [with _Kt = std::pair<int, int> [30010]]':
skyscraper.cpp:40:24:   required from here
/usr/include/c++/7/bits/stl_set.h:744:2: error: no matching function for call to 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_count_tr(const std::pair<int, int> [30010]) const'
In file included from /usr/include/c++/7/map:60:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:81,
                 from skyscraper.cpp:3:
/usr/include/c++/7/bits/stl_tree.h:1234:2: note: candidate: template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_count_tr(const _Kt&) const [with _Kt = _Kt; _Req = _Req; _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = std::less<int>; _Alloc = std::allocator<int>]
  _M_count_tr(const _Kt& __k) const
  ^~~~~~~~~~~
/usr/include/c++/7/bits/stl_tree.h:1234:2: note:   template argument deduction/substitution failed:
/usr/include/c++/7/bits/stl_tree.h:1231:9: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<int>, std::pair<int, int> [30010], void>'
         typename _Req =
         ^~~~~~~~
skyscraper.cpp:42:22: error: no matching function for call to 'std::set<int>::insert(pii [30010])'
  calced[pos].insert(p);
                      ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from skyscraper.cpp:3:
/usr/include/c++/7/bits/stl_set.h:499:7: note: candidate: std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree_const_iterator<int>; std::set<_Key, _Compare, _Alloc>::value_type = int] <near match>
       insert(const value_type& __x)
       ^~~~~~
/usr/include/c++/7/bits/stl_set.h:499:7: note:   conversion of argument 1 would be ill-formed:
skyscraper.cpp:42:22: error: invalid conversion from 'pii* {aka std::pair<int, int>*}' to 'std::set<int>::value_type {aka int}' [-fpermissive]
  calced[pos].insert(p);
                      ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from skyscraper.cpp:3:
/usr/include/c++/7/bits/stl_set.h:508:7: note: candidate: std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::value_type&&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree_const_iterator<int>; std::set<_Key, _Compare, _Alloc>::value_type = int] <near match>
       insert(value_type&& __x)
       ^~~~~~
/usr/include/c++/7/bits/stl_set.h:508:7: note:   conversion of argument 1 would be ill-formed:
skyscraper.cpp:42:22: error: invalid conversion from 'pii* {aka std::pair<int, int>*}' to 'std::set<int>::value_type {aka int}' [-fpermissive]
  calced[pos].insert(p);
                      ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from skyscraper.cpp:3:
/usr/include/c++/7/bits/stl_set.h:536:7: note: candidate: std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::const_iterator, const value_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<int>; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>; std::set<_Key, _Compare, _Alloc>::value_type = int]
       insert(const_iterator __position, const value_type& __x)
       ^~~~~~
/usr/include/c++/7/bits/stl_set.h:536:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/7/bits/stl_set.h:541:7: note: candidate: std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_Key, _Compare, _Alloc>::value_type&&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<int>; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<int>; std::set<_Key, _Compare, _Alloc>::value_type = int]
       insert(const_iterator __position, value_type&& __x)
       ^~~~~~
/usr/include/c++/7/bits/stl_set.h:541:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/7/bits/stl_set.h:556:2: note: candidate: template<class _InputIterator> void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]
  insert(_InputIterator __first, _InputIterator __last)
  ^~~~~~
/usr/include/c++/7/bits/stl_set.h:556:2: note:   template argument deduction/substitution failed:
skyscraper.cpp:42:22: note:   candidate expects 2 arguments, 1 provided
  calced[pos].insert(p);
                      ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from skyscraper.cpp:3:
/usr/include/c++/7/bits/stl_set.h:568:7: note: candidate: void std::set<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]
       insert(initializer_list<value_type> __l)
       ^~~~~~
/usr/include/c++/7/bits/stl_set.h:568:7: note:   no known conversion for argument 1 from 'pii [30010] {aka std::pair<int, int> [30010]}' to 'std::initializer_list<int>'
skyscraper.cpp:44:17: error: 'd' was not declared in this scope
      dis[pos] = d;
                 ^
skyscraper.cpp:49:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
  if(pos >= p)
            ^
skyscraper.cpp:50:26: error: invalid operands of types 'int' and 'pii [30010] {aka std::pair<int, int> [30010]}' to binary 'operator-'
      q.push_front({ {pos - p, p}, d + 1 });
                      ~~~~^~~
skyscraper.cpp:50:35: error: 'd' was not declared in this scope
      q.push_front({ {pos - p, p}, d + 1 });
                                   ^
skyscraper.cpp:51:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
  if(pos + p < n)
               ^
skyscraper.cpp:52:35: error: 'd' was not declared in this scope
      q.push_front({ {pos + p, p}, d + 1 });
                                   ^