# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
89120 | 2018-12-10T10:46:27 Z | tarash117 | 특수한 그래프 (IZhO13_specialg) | C++14 | 컴파일 오류 |
0 ms | 0 KB |
#include<bits/stdc++.h> using namespace std; int par[100001]; int used[100001]; int main(){ vector<int,int>ans; int n;cin>>n; int g[n+1][n+1]; for(int i=1;i<=n;i++){ int t;cin>>t; g[i][t]=1; par[i]=t; } int m;cin>>m; for(int i=1;i<=n;i++){ int t; cin>>t; if(t==1){ int a;cin>>a; for(int i=1;i<=n;i++) g[a][i]=0; par[a]=0; } if(t==2){ int a, b; cin>>a>>b; int cnt=0,ind=0; for(int i=a;i!=b;i=par[i]){ if(used[i]==1) break; cnt++; used[i]=1; } if(used[b]==1) ans.push_back(cnt); else cout<<-1; for(int i=1;i<=n;i++) used[i]=0; } } for(int i=0;i<ans.size();i++) cout<<ans[i]; return 0; }
Compilation message
In file included from /usr/include/c++/7/ext/alloc_traits.h:36:0, from /usr/include/c++/7/bits/basic_string.h:40, from /usr/include/c++/7/string:52, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, 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 specialg.cpp:1: /usr/include/c++/7/bits/alloc_traits.h: In instantiation of 'struct std::allocator_traits<int>': /usr/include/c++/7/ext/alloc_traits.h:50:10: required from 'struct __gnu_cxx::__alloc_traits<int>' /usr/include/c++/7/bits/stl_vector.h:77:21: required from 'struct std::_Vector_base<int, int>' /usr/include/c++/7/bits/stl_vector.h:216:11: required from 'class std::vector<int, int>' specialg.cpp:7:17: required from here /usr/include/c++/7/bits/alloc_traits.h:88:43: error: 'int' is not a class, struct, or union type typedef typename _Alloc::value_type value_type; ^~~~~~~~~~ /usr/include/c++/7/bits/alloc_traits.h:95:70: error: 'int' is not a class, struct, or union type using pointer = __detected_or_t<value_type*, __pointer, _Alloc>; ^ /usr/include/c++/7/bits/alloc_traits.h:135:79: error: 'int' is not a class, struct, or union type using const_pointer = typename _Ptr<__c_pointer, const value_type>::type; ^ /usr/include/c++/7/bits/alloc_traits.h: In instantiation of 'struct std::allocator_traits<int>::_Ptr<std::__allocator_traits_base::__v_pointer, void, void>': /usr/include/c++/7/bits/alloc_traits.h:143:66: required from 'struct std::allocator_traits<int>' /usr/include/c++/7/ext/alloc_traits.h:50:10: required from 'struct __gnu_cxx::__alloc_traits<int>' /usr/include/c++/7/bits/stl_vector.h:77:21: required from 'struct std::_Vector_base<int, int>' /usr/include/c++/7/bits/stl_vector.h:216:11: required from 'class std::vector<int, int>' specialg.cpp:7:17: required from here /usr/include/c++/7/bits/alloc_traits.h:102:71: error: 'int' is not a class, struct, or union type using type = typename pointer_traits<pointer>::template rebind<_Tp>; ^ /usr/include/c++/7/bits/alloc_traits.h: In instantiation of 'struct std::allocator_traits<int>::_Ptr<std::__allocator_traits_base::__cv_pointer, const void, void>': /usr/include/c++/7/bits/alloc_traits.h:151:79: required from 'struct std::allocator_traits<int>' /usr/include/c++/7/ext/alloc_traits.h:50:10: required from 'struct __gnu_cxx::__alloc_traits<int>' /usr/include/c++/7/bits/stl_vector.h:77:21: required from 'struct std::_Vector_base<int, int>' /usr/include/c++/7/bits/stl_vector.h:216:11: required from 'class std::vector<int, int>' specialg.cpp:7:17: required from here /usr/include/c++/7/bits/alloc_traits.h:102:71: error: 'int' is not a class, struct, or union type /usr/include/c++/7/bits/alloc_traits.h: In instantiation of 'struct std::allocator_traits<int>': /usr/include/c++/7/ext/alloc_traits.h:50:10: required from 'struct __gnu_cxx::__alloc_traits<int>' /usr/include/c++/7/bits/stl_vector.h:77:21: required from 'struct std::_Vector_base<int, int>' /usr/include/c++/7/bits/stl_vector.h:216:11: required from 'class std::vector<int, int>' specialg.cpp:7:17: required from here /usr/include/c++/7/bits/alloc_traits.h:159:68: error: 'int' is not a class, struct, or union type using difference_type = typename _Diff<_Alloc, pointer>::type; ^ /usr/include/c++/7/bits/alloc_traits.h:167:70: error: 'int' is not a class, struct, or union type using size_type = typename _Size<_Alloc, difference_type>::type; ^ In file included from /usr/include/c++/7/bits/basic_string.h:40:0, from /usr/include/c++/7/string:52, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, 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 specialg.cpp:1: /usr/include/c++/7/ext/alloc_traits.h: In instantiation of 'struct __gnu_cxx::__alloc_traits<int>': /usr/include/c++/7/bits/stl_vector.h:77:21: required from 'struct std::_Vector_base<int, int>' /usr/include/c++/7/bits/stl_vector.h:216:11: required from 'class std::vector<int, int>' specialg.cpp:7:17: required from here /usr/include/c++/7/ext/alloc_traits.h:66:23: error: no members matching '__gnu_cxx::__alloc_traits<int>::_Base_type {aka std::allocator_traits<int>}::allocate' in '__gnu_cxx::__alloc_traits<int>::_Base_type {aka struct std::allocator_traits<int>}' using _Base_type::allocate; ^~~~~~~~ /usr/include/c++/7/ext/alloc_traits.h:67:23: error: no members matching '__gnu_cxx::__alloc_traits<int>::_Base_type {aka std::allocator_traits<int>}::deallocate' in '__gnu_cxx::__alloc_traits<int>::_Base_type {aka struct std::allocator_traits<int>}' using _Base_type::deallocate; ^~~~~~~~~~ /usr/include/c++/7/ext/alloc_traits.h:70:23: error: no members matching '__gnu_cxx::__alloc_traits<int>::_Base_type {aka std::allocator_traits<int>}::max_size' in '__gnu_cxx::__alloc_traits<int>::_Base_type {aka struct std::allocator_traits<int>}' using _Base_type::max_size; ^~~~~~~~ In file included from /usr/include/c++/7/ext/alloc_traits.h:36:0, from /usr/include/c++/7/bits/basic_string.h:40, from /usr/include/c++/7/string:52, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, 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 specialg.cpp:1: /usr/include/c++/7/bits/alloc_traits.h: In substitution of 'template<class _Alloc, class _Up> using __alloc_rebind = typename std::__allocator_traits_base::__rebind<_Alloc, _Up>::type [with _Alloc = int; _Up = int]': /usr/include/c++/7/bits/alloc_traits.h:206:50: required by substitution of 'template<class _Alloc> template<class _Tp> using rebind_alloc = std::__alloc_rebind<_Alloc, _Tp> [with _Tp = int; _Alloc = int]' /usr/include/c++/7/ext/alloc_traits.h:117:65: required from 'struct __gnu_cxx::__alloc_traits<int>::rebind<int>' /usr/include/c++/7/bits/stl_vector.h:77:21: required from 'struct std::_Vector_base<int, int>' /usr/include/c++/7/bits/stl_vector.h:216:11: required from 'class std::vector<int, int>' specialg.cpp:7:17: required from here /usr/include/c++/7/bits/alloc_traits.h:76:79: error: no type named 'type' in 'struct std::__allocator_traits_base::__rebind<int, int, void>' = typename __allocator_traits_base::template __rebind<_Alloc, _Up>::type; ^ In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from specialg.cpp:1: /usr/include/c++/7/bits/stl_vector.h: In instantiation of 'class std::vector<int, int>': specialg.cpp:7:17: required from here /usr/include/c++/7/bits/stl_vector.h:247:20: error: no members matching 'std::vector<int, int>::_Base {aka std::_Vector_base<int, int>}::_M_allocate' in 'std::vector<int, int>::_Base {aka struct std::_Vector_base<int, int>}' using _Base::_M_allocate; ^~~~~~~~~~~ /usr/include/c++/7/bits/stl_vector.h:248:20: error: no members matching 'std::vector<int, int>::_Base {aka std::_Vector_base<int, int>}::_M_deallocate' in 'std::vector<int, int>::_Base {aka struct std::_Vector_base<int, int>}' using _Base::_M_deallocate; ^~~~~~~~~~~~~ /usr/include/c++/7/bits/stl_vector.h:250:20: error: no members matching 'std::vector<int, int>::_Base {aka std::_Vector_base<int, int>}::_M_get_Tp_allocator' in 'std::vector<int, int>::_Base {aka struct std::_Vector_base<int, int>}' using _Base::_M_get_Tp_allocator; ^~~~~~~~~~~~~~~~~~~ specialg.cpp: In function 'int main()': specialg.cpp:28:14: warning: unused variable 'ind' [-Wunused-variable] int cnt=0,ind=0; ^~~ specialg.cpp:44:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=0;i<ans.size();i++) ~^~~~~~~~~~~ specialg.cpp:45:12: error: no match for 'operator[]' (operand types are 'std::vector<int, int>' and 'int') cout<<ans[i]; ^ In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from specialg.cpp:1: /usr/include/c++/7/bits/stl_vector.h: In instantiation of 'std::vector<_Tp, _Alloc>::~vector() [with _Tp = int; _Alloc = int]': specialg.cpp:7:17: required from here /usr/include/c++/7/bits/stl_vector.h:434:37: error: 'struct std::_Vector_base<int, int>::_Vector_impl' has no member named '_M_start'; did you mean '_M_swap_data'? { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, ~~~~~~~~~~~~~~^~~~~~~~ _M_swap_data /usr/include/c++/7/bits/stl_vector.h:434:61: error: 'struct std::_Vector_base<int, int>::_Vector_impl' has no member named '_M_finish' { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, ~~~~~~~~~~~~~~^~~~~~~~~ /usr/include/c++/7/bits/stl_vector.h:435:28: error: '_M_get_Tp_allocator' was not declared in this scope _M_get_Tp_allocator()); } ~~~~~~~~~~~~~~~~~~~^~ /usr/include/c++/7/bits/stl_vector.h:435:28: note: suggested alternative: 'get_allocator' _M_get_Tp_allocator()); } ~~~~~~~~~~~~~~~~~~~^~ get_allocator /usr/include/c++/7/bits/stl_vector.h: In instantiation of 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = int; std::vector<_Tp, _Alloc>::value_type = int]': specialg.cpp:37:24: required from here /usr/include/c++/7/bits/stl_vector.h:941:20: error: 'struct std::_Vector_base<int, int>::_Vector_impl' has no member named '_M_finish' if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) ~~~~~~~~~~~~~~^~~~~~~~~ /usr/include/c++/7/bits/stl_vector.h:941:47: error: 'struct std::_Vector_base<int, int>::_Vector_impl' has no member named '_M_end_of_storage' if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/7/bits/stl_vector.h:943:60: error: 'struct std::_Vector_base<int, int>::_Vector_impl' has no member named '_M_finish' _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, ~~~~~~~~~~~~~~^~~~~~~~~ /usr/include/c++/7/bits/stl_vector.h:945:22: error: 'struct std::_Vector_base<int, int>::_Vector_impl' has no member named '_M_finish' ++this->_M_impl._M_finish; ~~~~~~~~~~~~~~^~~~~~~~~ /usr/include/c++/7/bits/stl_vector.h:948:25: error: no matching function for call to 'end()' _M_realloc_insert(end(), __x); ~~~^~ In file included from /usr/include/c++/7/bits/range_access.h:36:0, from /usr/include/c++/7/string:51, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, 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 specialg.cpp:1: /usr/include/c++/7/initializer_list:99:5: note: candidate: template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>) end(initializer_list<_Tp> __ils) noexcept ^~~ /usr/include/c++/7/initializer_list:99:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from specialg.cpp:1: /usr/include/c++/7/bits/stl_vector.h:948:25: note: candidate expects 1 argument, 0 provided _M_realloc_insert(end(), __x); ~~~^~ In file included from /usr/include/c++/7/string:51:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, 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 specialg.cpp:1: /usr/include/c++/7/bits/range_access.h:68:5: note: candidate: template<class _Container> decltype (__cont.end()) std::end(_Container&) end(_Container& __cont) -> decltype(__cont.end()) ^~~ /usr/include/c++/7/bits/range_access.h:68:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from specialg.cpp:1: /usr/include/c++/7/bits/stl_vector.h:948:25: note: candidate expects 1 argument, 0 provided _M_realloc_insert(end(), __x); ~~~^~ In file included from /usr/include/c++/7/string:51:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, 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 specialg.cpp:1: /usr/include/c++/7/bits/range_access.h:78:5: note: candidate: template<class _Container> decltype (__cont.end()) std::end(const _Container&) end(const _Container& __cont) -> decltype(__cont.end()) ^~~ /usr/include/c++/7/bits/range_access.h:78:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from specialg.cpp:1: /usr/include/c++/7/bits/stl_vector.h:948:25: note: candidate expects 1 argument, 0 provided _M_realloc_insert(end(), __x); ~~~^~ In file included from /usr/include/c++/7/string:51:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, 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 specialg.cpp:1: /usr/include/c++/7/bits/range_access.h:97:5: note: candidate: template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm]) end(_Tp (&__arr)[_Nm]) ^~~ /usr/include/c++/7/bits/range_access.h:97:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from specialg.cpp:1: /usr/include/c++/7/bits/stl_vector.h:948:25: note: candidate expects 1 argument, 0 provided _M_realloc_insert(end(), __x); ~~~^~ In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0, from specialg.cpp:1: /usr/include/c++/7/valarray:1221:5: note: candidate: template<class _Tp> _Tp* std::end(std::valarray<_Tp>&) end(valarray<_Tp>& __va) ^~~ /usr/include/c++/7/valarray:1221:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from specialg.cpp:1: /usr/include/c++/7/bits/stl_vector.h:948:25: note: candidate expects 1 argument, 0 provided _M_realloc_insert(end(), __x); ~~~^~ In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0, from specialg.cpp:1: /usr/include/c++/7/valarray:1231:5: note: candidate: template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&) end(const valarray<_Tp>& __va) ^~~ /usr/include/c++/7/valarray:1231:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/vector:64:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from specialg.cpp:1: /usr/include/c++/7/bits/stl_vector.h:948:25: note: candidate expects 1 argument, 0 provided _M_realloc_insert(end(), __x); ~~~^~ /usr/include/c++/7/bits/stl_vector.h:948:21: error: '_M_realloc_insert' was not declared in this scope _M_realloc_insert(end(), __x); ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ /usr/include/c++/7/bits/stl_vector.h: In instantiation of 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = int; std::vector<_Tp, _Alloc>::size_type = long unsigned int]': specialg.cpp:44