# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
733622 | 2023-05-01T05:14:43 Z | bin9638 | 철인 이종 경기 (APIO18_duathlon) | C++17 | 컴파일 오류 |
0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; #define N 200010 #define ll long long #define fs first #define sc second #define ii pair<int,int> #define pb push_back #define int ll int ans=0,times,num[N],low[N],n,m,ktr[N],dem,sz[N],child[N]; vector<int>g[N],edge[N]; stack<int>st; void visit(int u,int p) { num[u]=low[u]=++times; for(auto v:g[u]) if(v!=p) { if(num[v]!=0) { low[u]=min(low[u],num[v]); }else { st.push(u); visit(v,u); low[u]=min(low[u],low[v]); if(low[v]>=num[u]) { int k; dem++; do{ k=st.top(); st.pop(); if(ktr[k]!=dem) { sz[dem]++; ktr[k]=dem; edge[dem].pb(k); edge[k].pb(dem); } }while(k!=u); } } } st.push(u); } void build(int u,int p) { child[u]=(u<=n); //cout<<u<<" "<<child[u]<<endl; for(auto v:edge[u]) if(v!=p) { build(v,u); child[u]+=child[v]; } } void DFS(int u,int p) { if(u<=n) { int sum=n-1; for(auto v:edge[u]) if(v!=p) { sum-=child[v]; ans+=sum*child[v]; // cout<<sum<<" "<<child[v]<<endl; } }else { int sum=n; for(auto v:edge[u]) if(v!=p) { sum-=child[v]; ans+=sum*child[v]*(sz[u]-2); // cout<<u<<" "<<sum<<" "<<child[v]<<" "<<sz[u]<<endl; } } //cout<<u<<" "<<ans*2<<endl; for(auto v:edge[u]) if(v!=p) DFS(v,u); } int32_t main() { // freopen("A.inp","r",stdin); // freopen("A.out","w",stdout); ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>n>>m; for(int i=1;i<=m;i++) { int u,v; cin>>u>>v; g[u].pb(v); g[v].pb(u); } dem=n; for(int i=1;i<=n;i++) if(num[i]==0) visit(i,0); //cout<<dem<<endl; build(1,0); // cout<<child[1]<<endl; DFS(1,0); cout<<ans*2; return 0; }
Compilation message
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from count_triplets.cpp:1: /usr/include/c++/10/variant: In instantiation of 'constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...) [with _Visitor = long long int&; _Variants = {int}]': count_triplets.cpp:112:22: required from here /usr/include/c++/10/variant:1702:23: error: request for member 'valueless_by_exception' in '__variants#0', which is of non-class type 'int' 1702 | if ((__variants.valueless_by_exception() || ...)) | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/10/variant:1706:22: error: no matching function for call to 'get<0>(int)' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from count_triplets.cpp:1: /usr/include/c++/10/utility:223:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)' 223 | get(std::pair<_Tp1, _Tp2>& __in) noexcept | ^~~ /usr/include/c++/10/utility:223:5: note: template argument deduction/substitution failed: In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from count_triplets.cpp:1: /usr/include/c++/10/variant:1706:22: note: mismatched types 'std::pair<_Tp1, _Tp2>' and 'int' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from count_triplets.cpp:1: /usr/include/c++/10/utility:228:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)' 228 | get(std::pair<_Tp1, _Tp2>&& __in) noexcept | ^~~ /usr/include/c++/10/utility:228:5: note: template argument deduction/substitution failed: In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from count_triplets.cpp:1: /usr/include/c++/10/variant:1706:22: note: mismatched types 'std::pair<_Tp1, _Tp2>' and 'int' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from count_triplets.cpp:1: /usr/include/c++/10/utility:233:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const std::pair<_Tp1, _Tp2>&)' 233 | get(const std::pair<_Tp1, _Tp2>& __in) noexcept | ^~~ /usr/include/c++/10/utility:233:5: note: template argument deduction/substitution failed: In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from count_triplets.cpp:1: /usr/include/c++/10/variant:1706:22: note: mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from count_triplets.cpp:1: /usr/include/c++/10/utility:238:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const std::pair<_Tp1, _Tp2>&&)' 238 | get(const std::pair<_Tp1, _Tp2>&& __in) noexcept | ^~~ /usr/include/c++/10/utility:238:5: note: template argument deduction/substitution failed: In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from count_triplets.cpp:1: /usr/include/c++/10/variant:1706:22: note: mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from count_triplets.cpp:1: /usr/include/c++/10/utility:247:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_T1, _T2>&)' 247 | get(pair<_Tp, _Up>& __p) noexcept | ^~~ /usr/include/c++/10/utility:247:5: note: template argument deduction/substitution failed: /usr/include/c++/10/utility:252:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_T1, _T2>&)' 252 | get(const pair<_Tp, _Up>& __p) noexcept | ^~~ /usr/include/c++/10/utility:252:5: note: template argument deduction/substitution failed: /usr/include/c++/10/utility:257:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_T1, _T2>&&)' 257 | get(pair<_Tp, _Up>&& __p) noexcept | ^~~ /usr/include/c++/10/utility:257:5: note: template argument deduction/substitution failed: /usr/include/c++/10/utility:262:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_T1, _T2>&&)' 262 | get(const pair<_Tp, _Up>&& __p) noexcept | ^~~ /usr/include/c++/10/utility:262:5: note: template argument deduction/substitution failed: /usr/include/c++/10/utility:267:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_Up, _Tp>&)' 267 | get(pair<_Up, _Tp>& __p) noexcept | ^~~ /usr/include/c++/10/utility:267:5: note: template argument deduction/substitution failed: /usr/include/c++/10/utility:272:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_Up, _Tp>&)' 272 | get(const pair<_Up, _Tp>& __p) noexcept | ^~~ /usr/include/c++/10/utility:272:5: note: template argument deduction/substitution failed: /usr/include/c++/10/utility:277:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_Up, _Tp>&&)' 277 | get(pair<_Up, _Tp>&& __p) noexcept | ^~~ /usr/include/c++/10/utility:277:5: note: template argument deduction/substitution failed: /usr/include/c++/10/utility:282:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_Up, _Tp>&&)' 282 | get(const pair<_Up, _Tp>&& __p) noexcept | ^~~ /usr/include/c++/10/utility:282:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/10/tuple:39, from /usr/include/c++/10/functional:54, from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from count_triplets.cpp:1: /usr/include/c++/10/array:334:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(std::array<_Tp, _Nm>&)' 334 | get(array<_Tp, _Nm>& __arr) noexcept | ^~~ /usr/include/c++/10/array:334:5: note: template argument deduction/substitution failed: In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from count_triplets.cpp:1: /usr/include/c++/10/variant:1706:22: note: mismatched types 'std::array<_Tp, _Nm>' and 'int' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/10/tuple:39, from /usr/include/c++/10/functional:54, from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from count_triplets.cpp:1: /usr/include/c++/10/array:343:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(std::array<_Tp, _Nm>&&)' 343 | get(array<_Tp, _Nm>&& __arr) noexcept | ^~~ /usr/include/c++/10/array:343:5: note: template argument deduction/substitution failed: In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from count_triplets.cpp:1: /usr/include/c++/10/variant:1706:22: note: mismatched types 'std::array<_Tp, _Nm>' and 'int' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/10/tuple:39, from /usr/include/c++/10/functional:54, from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from count_triplets.cpp:1: /usr/include/c++/10/array:351:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const std::array<_Tp, _Nm>&)' 351 | get(const array<_Tp, _Nm>& __arr) noexcept | ^~~ /usr/include/c++/10/array:351:5: note: template argument deduction/substitution failed: In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from count_triplets.cpp:1: /usr/include/c++/10/variant:1706:22: note: mismatched types 'const std::array<_Tp, _Nm>' and 'int' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/10/tuple:39, from /usr/include/c++/10/functional:54, from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from count_triplets.cpp:1: /usr/include/c++/10/array:360:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const std::array<_Tp, _Nm>&&)' 360 | get(const array<_Tp, _Nm>&& __arr) noexcept | ^~~ /usr/include/c++/10/array:360:5: note: template argument deduction/substitution failed: In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from count_triplets.cpp:1: /usr/include/c++/10/variant:1706:22: note: mismatched types 'const std::array<_Tp, _Nm>' and 'int' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/10/functional:54, from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from count_triplets.cpp:1: /usr/include/c++/10/tuple:1294:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >& std::get(std::tuple<_UTypes ...>&)' 1294 | get(tuple<_Elements...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1294:5: note: template argument deduction/substitution failed: In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from count_triplets.cpp:1: /usr/include/c++/10/variant:1706:22: note: mismatched types 'std::tuple<_UTypes ...>' and 'int' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/10/functional:54, from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from count_triplets.cpp:1: /usr/include/c++/10/tuple:1300:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >& std::get(const std::tuple<_UTypes ...>&)' 1300 | get(const tuple<_Elements...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1300:5: note: template argument deduction/substitution failed: In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from count_triplets.cpp:1: /usr/include/c++/10/variant:1706:22: note: mismatched types 'const std::tuple<_UTypes ...>' and 'int' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/10/functional:54, from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from count_triplets.cpp:1: /usr/include/c++/10/tuple:1306:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >&& std::get(std::tuple<_UTypes ...>&&)' 1306 | get(tuple<_Elements...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1306:5: note: template argument deduction/substitution failed: In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from count_triplets.cpp:1: /usr/include/c++/10/variant:1706:22: note: mismatched types 'std::tuple<_UTypes ...>' and 'int' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/10/functional:54, from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from count_triplets.cpp:1: /usr/include/c++/10/tuple:1315:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >&& std::get(const std::tuple<_UTypes ...>&&)' 1315 | get(const tuple<_Elements...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1315:5: note: template argument deduction/substitution failed: In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from count_triplets.cpp:1: /usr/include/c++/10/variant:1706:22: note: mismatched types 'const std::tuple<_UTypes ...>' and 'int' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/10/functional:54, from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from count_triplets.cpp:1: /usr/include/c++/10/tuple:1338:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::tuple<_UTypes ...>&)' 1338 | get(tuple<_Types...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1338:5: note: template argument deduction/substitution failed: /usr/include/c++/10/tuple:1344:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::tuple<_UTypes ...>&&)' 1344 | get(tuple<_Types...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1344:5: note: template argument deduction/substitution failed: /usr/include/c++/10/tuple:1350:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const std::tuple<_UTypes ...>&)' 1350 | get(const tuple<_Types...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1350:5: note: template argument deduction/substitution failed: /usr/include/c++/10/tuple:1357:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const std::tuple<_UTypes ...>&&)' 1357 | get(const tuple<_Types...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1357:5: note: template argument deduction/substitution failed: In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from count_triplets.cpp:1: /usr/include/c++/10/variant:1644:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(std::variant<_Types ...>&)' 1644 | get(variant<_Types...>& __v) | ^~~ /usr/include/c++/10/variant:1644:5: note: template argument deduction/substitution failed: /usr/include/c++/10/variant:1706:22: note: mismatched types 'std::variant<_Types ...>' and 'int' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/10/variant:1655:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >&& std::get(std::variant<_Types ...>&&)' 1655 | get(variant<_Types...>&& __v) | ^~~ /usr/include/c++/10/variant:1655:5: note: template argument deduction/substitution failed: /usr/include/c++/10/variant:1706:22: note: mismatched types 'std::variant<_Types ...>' and 'int' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/10/variant:1666:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(const std::variant<_Types ...>&)' 1666 | get(const variant<_Types...>& __v) | ^~~ /usr/include/c++/10/variant:1666:5: note: template argument deduction/substitution failed: /usr/include/c++/10/variant:1706:22: note: mismatched types 'const std::variant<_Types ...>' and 'int' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/10/variant:1677:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >&& std::get(const std::variant<_Types ...>&&)' 1677 | get(const variant<_Types...>&& __v) | ^~~ /usr/include/c++/10/variant:1677:5: note: template argument deduction/substitution failed: /usr/include/c++/10/variant:1706:22: note: mismatched types 'const std::variant<_Types ...>' and 'int' 1706 | decltype(std::get<0>(std::declval<_Variants>()))...>; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/10/variant:1071:20: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::variant<_Types ...>&)' 1071