# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
621240 | 2022-08-03T15:28:08 Z | moyindavid | 분수 공원 (IOI21_parks) | C++17 | 컴파일 오류 |
0 ms | 0 KB |
#include <bits/stdc++.h> #include "parks.h" #define pb push_back using namespace std; vector<bool> vis(200100,false);int cnt=0;set<int> node[200100];vector<int> u,v,a,b; void dsf(int i, vector<int> x, vector<int> y){ vis[i]=true; cnt++; for(auto j: node[i]){ if(!vis[j]){ u.pb(i);v.pb(j); if(x[i]==x[j]){ b.pb((y[i]+y[j])/2); if(x[i]==2)a.pb(x[i]-1); else a.pb(x[i]+1); } else{ a.pb((x[i]+x[j])/2); b.pb(y[i]-1); } dsf(j,x,y); } } } int construct_roads(vector<int> x, vector<int> y){ map<pair<int,int>,bool> m; map<pair<int,int>,int> n; for(int i=0;i<x.size();i++){ m[{x[i],y[i]}]=1; n[{x[i],y[i]}]=i; } for(int i=0;i<x.size();i++){ if(m.count([{x[i]-2,y[i]}])){node[i].insert(n[{x[i]-2,y[i]}]);node[n[{x[i]-2,y[i]}]].insert(i);} if(m.count([{x[i]+2,y[i]}])){node[i].insert(n[{x[i]+2,y[i]}]);node[n[{x[i]+2,y[i]}]].insert(i);} if(m.count([{x[i],y[i]-2}])){node[i].insert(n[{x[i],y[i]-2}]);node[n[{x[i],y[i]-2}]].insert(i);} if(m.count([{x[i],y[i]+2}])){node[i].insert(n[{x[i],y[i]+2}]);node[n[{x[i],y[i]+2}]].insert(i);} } dsf(0,x,y); if(cnt==x.size()){ build(u,v,a,b); return 1; } return 0; }
Compilation message
parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)': parks.cpp:35:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 35 | for(int i=0;i<x.size();i++){ | ~^~~~~~~~~ parks.cpp:40:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 40 | for(int i=0;i<x.size();i++){ | ~^~~~~~~~~ parks.cpp:41:21: error: expected identifier before '{' token 41 | if(m.count([{x[i]-2,y[i]}])){node[i].insert(n[{x[i]-2,y[i]}]);node[n[{x[i]-2,y[i]}]].insert(i);} | ^ parks.cpp: In lambda function: parks.cpp:41:35: error: expected '{' before ')' token 41 | if(m.count([{x[i]-2,y[i]}])){node[i].insert(n[{x[i]-2,y[i]}]);node[n[{x[i]-2,y[i]}]].insert(i);} | ^ parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)': parks.cpp:41:35: error: no matching function for call to 'std::map<std::pair<int, int>, bool>::count(construct_roads(std::vector<int>, std::vector<int>)::<lambda()>)' In file included from /usr/include/c++/10/map:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81, from parks.cpp:1: /usr/include/c++/10/bits/stl_map.h:1215:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::size_type std::map<_Key, _Tp, _Compare, _Alloc>::count(const key_type&) const [with _Key = std::pair<int, int>; _Tp = bool; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >; std::map<_Key, _Tp, _Compare, _Alloc>::size_type = long unsigned int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]' 1215 | count(const key_type& __x) const | ^~~~~ /usr/include/c++/10/bits/stl_map.h:1215:29: note: no known conversion for argument 1 from 'construct_roads(std::vector<int>, std::vector<int>)::<lambda()>' to 'const key_type&' {aka 'const std::pair<int, int>&'} 1215 | count(const key_type& __x) const | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_map.h:1221:2: note: candidate: 'template<class _Kt> decltype (((const std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::count(const _Kt&) const [with _Kt = _Kt; _Key = std::pair<int, int>; _Tp = bool; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >]' 1221 | count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) | ^~~~~ /usr/include/c++/10/bits/stl_map.h:1221:2: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/stl_map.h: In substitution of 'template<class _Kt> decltype (((const std::map<std::pair<int, int>, bool>*)this)->std::map<std::pair<int, int>, bool>::_M_t.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, bool>, std::_Select1st<std::pair<const std::pair<int, int>, bool> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, bool> > >::_M_count_tr<_Kt, _Req>(__x)) std::map<std::pair<int, int>, bool>::count<_Kt>(const _Kt&) const [with _Kt = construct_roads(std::vector<int>, std::vector<int>)::<lambda()>]': parks.cpp:41:35: required from here /usr/include/c++/10/bits/stl_map.h:1221:58: error: no matching function for call to 'std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, bool>, std::_Select1st<std::pair<const std::pair<int, int>, bool> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, bool> > >::_M_count_tr(const construct_roads(std::vector<int>, std::vector<int>)::<lambda()>&) const' 1221 | count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) | ~~~~~~~~~~~~~~~~^~~~~ In file included from /usr/include/c++/10/map:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81, from parks.cpp:1: /usr/include/c++/10/bits/stl_tree.h:1321: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 = std::pair<int, int>; _Val = std::pair<const std::pair<int, int>, bool>; _KeyOfValue = std::_Select1st<std::pair<const std::pair<int, int>, bool> >; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >]' 1321 | _M_count_tr(const _Kt& __k) const | ^~~~~~~~~~~ /usr/include/c++/10/bits/stl_tree.h:1321:2: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/stl_tree.h: In substitution of 'template<class _Cmp, class _SfinaeType> using __has_is_transparent_t = typename std::__has_is_transparent<_Cmp, _SfinaeType>::type [with _Cmp = std::less<std::pair<int, int> >; _SfinaeType = construct_roads(std::vector<int>, std::vector<int>)::<lambda()>]': /usr/include/c++/10/bits/stl_tree.h:1319:9: required by substitution of 'template<class _Kt> decltype (((const std::map<std::pair<int, int>, bool>*)this)->std::map<std::pair<int, int>, bool>::_M_t.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, bool>, std::_Select1st<std::pair<const std::pair<int, int>, bool> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, bool> > >::_M_count_tr<_Kt, _Req>(__x)) std::map<std::pair<int, int>, bool>::count<_Kt>(const _Kt&) const [with _Kt = construct_roads(std::vector<int>, std::vector<int>)::<lambda()>]' parks.cpp:41:35: required from here /usr/include/c++/10/bits/stl_tree.h:429:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<std::pair<int, int> >, construct_roads(std::vector<int>, std::vector<int>)::<lambda()>, void>' 429 | using __has_is_transparent_t | ^~~~~~~~~~~~~~~~~~~~~~ parks.cpp:42:21: error: expected identifier before '{' token 42 | if(m.count([{x[i]+2,y[i]}])){node[i].insert(n[{x[i]+2,y[i]}]);node[n[{x[i]+2,y[i]}]].insert(i);} | ^ parks.cpp: In lambda function: parks.cpp:42:35: error: expected '{' before ')' token 42 | if(m.count([{x[i]+2,y[i]}])){node[i].insert(n[{x[i]+2,y[i]}]);node[n[{x[i]+2,y[i]}]].insert(i);} | ^ parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)': parks.cpp:42:35: error: no matching function for call to 'std::map<std::pair<int, int>, bool>::count(construct_roads(std::vector<int>, std::vector<int>)::<lambda()>)' In file included from /usr/include/c++/10/map:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81, from parks.cpp:1: /usr/include/c++/10/bits/stl_map.h:1215:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::size_type std::map<_Key, _Tp, _Compare, _Alloc>::count(const key_type&) const [with _Key = std::pair<int, int>; _Tp = bool; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >; std::map<_Key, _Tp, _Compare, _Alloc>::size_type = long unsigned int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]' 1215 | count(const key_type& __x) const | ^~~~~ /usr/include/c++/10/bits/stl_map.h:1215:29: note: no known conversion for argument 1 from 'construct_roads(std::vector<int>, std::vector<int>)::<lambda()>' to 'const key_type&' {aka 'const std::pair<int, int>&'} 1215 | count(const key_type& __x) const | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_map.h:1221:2: note: candidate: 'template<class _Kt> decltype (((const std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::count(const _Kt&) const [with _Kt = _Kt; _Key = std::pair<int, int>; _Tp = bool; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >]' 1221 | count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) | ^~~~~ /usr/include/c++/10/bits/stl_map.h:1221:2: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/stl_map.h: In substitution of 'template<class _Kt> decltype (((const std::map<std::pair<int, int>, bool>*)this)->std::map<std::pair<int, int>, bool>::_M_t.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, bool>, std::_Select1st<std::pair<const std::pair<int, int>, bool> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, bool> > >::_M_count_tr<_Kt, _Req>(__x)) std::map<std::pair<int, int>, bool>::count<_Kt>(const _Kt&) const [with _Kt = construct_roads(std::vector<int>, std::vector<int>)::<lambda()>]': parks.cpp:42:35: required from here /usr/include/c++/10/bits/stl_map.h:1221:58: error: no matching function for call to 'std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, bool>, std::_Select1st<std::pair<const std::pair<int, int>, bool> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, bool> > >::_M_count_tr(const construct_roads(std::vector<int>, std::vector<int>)::<lambda()>&) const' 1221 | count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) | ~~~~~~~~~~~~~~~~^~~~~ In file included from /usr/include/c++/10/map:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81, from parks.cpp:1: /usr/include/c++/10/bits/stl_tree.h:1321: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 = std::pair<int, int>; _Val = std::pair<const std::pair<int, int>, bool>; _KeyOfValue = std::_Select1st<std::pair<const std::pair<int, int>, bool> >; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >]' 1321 | _M_count_tr(const _Kt& __k) const | ^~~~~~~~~~~ /usr/include/c++/10/bits/stl_tree.h:1321:2: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/stl_tree.h: In substitution of 'template<class _Cmp, class _SfinaeType> using __has_is_transparent_t = typename std::__has_is_transparent<_Cmp, _SfinaeType>::type [with _Cmp = std::less<std::pair<int, int> >; _SfinaeType = construct_roads(std::vector<int>, std::vector<int>)::<lambda()>]': /usr/include/c++/10/bits/stl_tree.h:1319:9: required by substitution of 'template<class _Kt> decltype (((const std::map<std::pair<int, int>, bool>*)this)->std::map<std::pair<int, int>, bool>::_M_t.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, bool>, std::_Select1st<std::pair<const std::pair<int, int>, bool> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, bool> > >::_M_count_tr<_Kt, _Req>(__x)) std::map<std::pair<int, int>, bool>::count<_Kt>(const _Kt&) const [with _Kt = construct_roads(std::vector<int>, std::vector<int>)::<lambda()>]' parks.cpp:42:35: required from here /usr/include/c++/10/bits/stl_tree.h:429:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<std::pair<int, int> >, construct_roads(std::vector<int>, std::vector<int>)::<lambda()>, void>' 429 | using __has_is_transparent_t | ^~~~~~~~~~~~~~~~~~~~~~ parks.cpp:43:21: error: expected identifier before '{' token 43 | if(m.count([{x[i],y[i]-2}])){node[i].insert(n[{x[i],y[i]-2}]);node[n[{x[i],y[i]-2}]].insert(i);} | ^ parks.cpp: In lambda function: parks.cpp:43:35: error: expected '{' before ')' token 43 | if(m.count([{x[i],y[i]-2}])){node[i].insert(n[{x[i],y[i]-2}]);node[n[{x[i],y[i]-2}]].insert(i);} | ^ parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)': parks.cpp:43:35: error: no matching function for call to 'std::map<std::pair<int, int>, bool>::count(construct_roads(std::vector<int>, std::vector<int>)::<lambda()>)' In file included from /usr/include/c++/10/map:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81, from parks.cpp:1: /usr/include/c++/10/bits/stl_map.h:1215:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::size_type std::map<_Key, _Tp, _Compare, _Alloc>::count(const key_type&) const [with _Key = std::pair<int, int>; _Tp = bool; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >; std::map<_Key, _Tp, _Compare, _Alloc>::size_type = long unsigned int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]' 1215 | count(const key_type& __x) const | ^~~~~ /usr/include/c++/10/bits/stl_map.h:1215:29: note: no known conversion for argument 1 from 'construct_roads(std::vector<int>, std::vector<int>)::<lambda()>' to 'const key_type&' {aka 'const std::pair<int, int>&'} 1215 | count(const key_type& __x) const | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_map.h:1221:2: note: candidate: 'template<class _Kt> decltype (((const std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::count(const _Kt&) const [with _Kt = _Kt; _Key = std::pair<int, int>; _Tp = bool; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >]' 1221 | count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) | ^~~~~ /usr/include/c++/10/bits/stl_map.h:1221:2: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/stl_map.h: In substitution of 'template<class _Kt> decltype (((const std::map<std::pair<int, int>, bool>*)this)->std::map<std::pair<int, int>, bool>::_M_t.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, bool>, std::_Select1st<std::pair<const std::pair<int, int>, bool> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, bool> > >::_M_count_tr<_Kt, _Req>(__x)) std::map<std::pair<int, int>, bool>::count<_Kt>(const _Kt&) const [with _Kt = construct_roads(std::vector<int>, std::vector<int>)::<lambda()>]': parks.cpp:43:35: required from here /usr/include/c++/10/bits/stl_map.h:1221:58: error: no matching function for call to 'std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, bool>, std::_Select1st<std::pair<const std::pair<int, int>, bool> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, bool> > >::_M_count_tr(const construct_roads(std::vector<int>, std::vector<int>)::<lambda()>&) const' 1221 | count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) | ~~~~~~~~~~~~~~~~^~~~~ In file included from /usr/include/c++/10/map:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81, from parks.cpp:1: /usr/include/c++/10/bits/stl_tree.h:1321: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 = std::pair<int, int>; _Val = std::pair<const std::pair<int, int>, bool>; _KeyOfValue = std::_Select1st<std::pair<const std::pair<int, int>, bool> >; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >]' 1321 | _M_count_tr(const _Kt& __k) const | ^~~~~~~~~~~ /usr/include/c++/10/bits/stl_tree.h:1321:2: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/stl_tree.h: In substitution of 'template<class _Cmp, class _SfinaeType> using __has_is_transparent_t = typename std::__has_is_transparent<_Cmp, _SfinaeType>::type [with _Cmp = std::less<std::pair<int, int> >; _SfinaeType = construct_roads(std::vector<int>, std::vector<int>)::<lambda()>]': /usr/include/c++/10/bits/stl_tree.h:1319:9: required by substitution of 'template<class _Kt> decltype (((const std::map<std::pair<int, int>, bool>*)this)->std::map<std::pair<int, int>, bool>::_M_t.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, bool>, std::_Select1st<std::pair<const std::pair<int, int>, bool> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, bool> > >::_M_count_tr<_Kt, _Req>(__x)) std::map<std::pair<int, int>, bool>::count<_Kt>(const _Kt&) const [with _Kt = construct_roads(std::vector<int>, std::vector<int>)::<lambda()>]' parks.cpp:43:35: required from here /usr/include/c++/10/bits/stl_tree.h:429:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<std::pair<int, int> >, construct_roads(std::vector<int>, std::vector<int>)::<lambda()>, void>' 429 | using __has_is_transparent_t | ^~~~~~~~~~~~~~~~~~~~~~ parks.cpp:44:21: error: expected identifier before '{' token 44 | if(m.count([{x[i],y[i]+2}])){node[i].insert(n[{x[i],y[i]+2}]);node[n[{x[i],y[i]+2}]].insert(i);} | ^ parks.cpp: In lambda function: parks.cpp:44:35: error: expected '{' before ')' token 44 | if(m.count([{x[i],y[i]+2}])){node[i].insert(n[{x[i],y[i]+2}]);node[n[{x[i],y[i]+2}]].insert(i);} | ^ parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)': parks.cpp:44:35: error: no matching function for call to 'std::map<std::pair<int, int>, bool>::count(construct_roads(std::vector<int>, std::vector<int>)::<lambda()>)' In file included from /usr/include/c++/10/map:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81, from parks.cpp:1: /usr/include/c++/10/bits/stl_map.h:1215:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::size_type std::map<_Key, _Tp, _Compare, _Alloc>::count(const key_type&) const [with _Key = std::pair<int, int>; _Tp = bool; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >; std::map<_Key, _Tp, _Compare, _Alloc>::size_type = long unsigned int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]' 1215 | c