| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1348507 | Faisal_Saqib | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 컴파일 에러 | 0 ms | 0 KiB |
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
const int N=1005;
int par2[N],par1[N],sz[N];
int get1(int x)
{
return (par[x]==x)?x:par[x]=get(par[x]);
}
void merge1(int x,int y)
{
x=get1(x),y=get1(y);
if(x==y)return;
par[x]=y;
}
int get2(int x)
{
return (par2[x]==x)?x:par2[x]=get(par2[x]);
}
void merge2(int x,int y)
{
x=get2(x),y=get2(y);
if(x==y)return;
par2[x]=y;
}
int construct(std::vector<std::vector<int>> p) {
int n = p.size();
auto ans=p;
for(int i=0;i<n;i++)par1[i]=par2[i]=i;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
ans[i][j]=0;
if(p[i][j]==3)
{
return 0;
}
if(p[i][j]==2)
{
merge2(i,j);
}
else if(p[i][j]>0)
{
merge1(i,j);
}
}
}
for(int i=0;i<n;i++)
{
sz[i]=0;
if(get2(i)==i)
{
vector<int> cur;
for(int j=0;j<n;j++)
{
if(i==get2(j))
{
cur.push_back(j);
}
}
sz[i]=cur.size();
for(auto c:cur)
{
for(auto d:cur)
{
if(c==d)continue;
if(p[c][d]<2)
{
return 0;
}
}
}
if(cur.size()==2)
{
// requires multiedges but we cant add multi
return 0;
}
for(int j=0;j+1<cur.size();j++)
{
ans[cur[j]][cur[j+1]]=1;
ans[cur[j+1]][cur[j]]=1;
}
ans[cur.back()][cur[0]]=1;
ans[cur[0]][cur.back()]=1;
}
}
for(int i=0;i<n;i++)
{
if(get1(i)==i)
{
vector<int> cur;
for(int j=0;j<n;j++)
{
if(i==get1(j))
{
cur.push_back(j);
}
}
for(auto c:cur)
{
for(auto d:cur)
{
if(c==d)continue;
if(p[c][d]<1)
{
return 0;
}
}
}
for(int j=0;j+1<cur.size();j++)
{
ans[cur[j]][cur[j+1]]=1;
ans[cur[j+1]][cur[j]]=1;
}
}
}
for(int i=0;i<n;i++)ans[i][i]=0;
build(ans);
return 1;
}
컴파일 시 표준 에러 (stderr) 메시지
supertrees.cpp: In function 'int get1(int)':
supertrees.cpp:8:17: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
8 | return (par[x]==x)?x:par[x]=get(par[x]);
| ^~~
| __pstl::execution::v1::par
In file included from /usr/include/c++/13/pstl/glue_algorithm_defs.h:15,
from /usr/include/c++/13/algorithm:73,
from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
from supertrees.cpp:2:
/usr/include/c++/13/pstl/execution_defs.h:111:45: note: '__pstl::execution::v1::par' declared here
111 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
| ^~~
supertrees.cpp: In function 'void merge1(int, int)':
supertrees.cpp:14:9: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
14 | par[x]=y;
| ^~~
| __pstl::execution::v1::par
/usr/include/c++/13/pstl/execution_defs.h:111:45: note: '__pstl::execution::v1::par' declared here
111 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
| ^~~
supertrees.cpp: In function 'int get2(int)':
supertrees.cpp:18:42: error: no matching function for call to 'get(int&)'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
from /usr/include/c++/13/vector:62,
from supertrees.h:1,
from supertrees.cpp:1:
/usr/include/c++/13/bits/stl_pair.h:1035: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(pair<_Tp1, _Tp2>&)'
1035 | get(pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/13/bits/stl_pair.h:1035:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'std::pair<_Tp1, _Tp2>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1040: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(pair<_Tp1, _Tp2>&&)'
1040 | get(pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/13/bits/stl_pair.h:1040:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'std::pair<_Tp1, _Tp2>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1045: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 pair<_Tp1, _Tp2>&)'
1045 | get(const pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/13/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1050: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 pair<_Tp1, _Tp2>&&)'
1050 | get(const pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/13/bits/stl_pair.h:1050:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1059:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_T1, _T2>&)'
1059 | get(pair<_Tp, _Up>& __p) noexcept
| ^~~
/usr/include/c++/13/bits/stl_pair.h:1059:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'std::pair<_T1, _T2>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1064:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_T1, _T2>&)'
1064 | get(const pair<_Tp, _Up>& __p) noexcept
| ^~~
/usr/include/c++/13/bits/stl_pair.h:1064:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::pair<_T1, _T2>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1069:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_T1, _T2>&&)'
1069 | get(pair<_Tp, _Up>&& __p) noexcept
| ^~~
/usr/include/c++/13/bits/stl_pair.h:1069:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'std::pair<_T1, _T2>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1074:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_T1, _T2>&&)'
1074 | get(const pair<_Tp, _Up>&& __p) noexcept
| ^~~
/usr/include/c++/13/bits/stl_pair.h:1074:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::pair<_T1, _T2>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1079:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_Up, _Tp>&)'
1079 | get(pair<_Up, _Tp>& __p) noexcept
| ^~~
/usr/include/c++/13/bits/stl_pair.h:1079:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'std::pair<_Up, _Tp>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1084:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_Up, _Tp>&)'
1084 | get(const pair<_Up, _Tp>& __p) noexcept
| ^~~
/usr/include/c++/13/bits/stl_pair.h:1084:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::pair<_Up, _Tp>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1089:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_Up, _Tp>&&)'
1089 | get(pair<_Up, _Tp>&& __p) noexcept
| ^~~
/usr/include/c++/13/bits/stl_pair.h:1089:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'std::pair<_Up, _Tp>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:1094:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_Up, _Tp>&&)'
1094 | get(const pair<_Up, _Tp>&& __p) noexcept
| ^~~
/usr/include/c++/13/bits/stl_pair.h:1094:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::pair<_Up, _Tp>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
In file included from /usr/include/c++/13/bits/memory_resource.h:47,
from /usr/include/c++/13/vector:80:
/usr/include/c++/13/tuple:1803:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >& std::get(tuple<_UTypes ...>&)'
1803 | get(tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/13/tuple:1803:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'std::tuple<_UTypes ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/tuple:1809:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >& std::get(const tuple<_UTypes ...>&)'
1809 | get(const tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/13/tuple:1809:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::tuple<_UTypes ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/tuple:1815:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >&& std::get(tuple<_UTypes ...>&&)'
1815 | get(tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/13/tuple:1815:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'std::tuple<_UTypes ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/tuple:1824:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >&& std::get(const tuple<_UTypes ...>&&)'
1824 | get(const tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/13/tuple:1824:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::tuple<_UTypes ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/tuple:1834:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_UTypes ...>&)' (deleted)
1834 | get(const tuple<_Elements...>&) = delete;
| ^~~
/usr/include/c++/13/tuple:1834:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::tuple<_UTypes ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/tuple:1844:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(tuple<_UTypes ...>&)'
1844 | get(tuple<_Types...>& __t) noexcept
| ^~~
/usr/include/c++/13/tuple:1844:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'std::tuple<_UTypes ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/tuple:1855:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(tuple<_UTypes ...>&&)'
1855 | get(tuple<_Types...>&& __t) noexcept
| ^~~
/usr/include/c++/13/tuple:1855:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'std::tuple<_UTypes ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/tuple:1866:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const tuple<_UTypes ...>&)'
1866 | get(const tuple<_Types...>& __t) noexcept
| ^~~
/usr/include/c++/13/tuple:1866:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::tuple<_UTypes ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/tuple:1878:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const tuple<_UTypes ...>&&)'
1878 | get(const tuple<_Types...>&& __t) noexcept
| ^~~
/usr/include/c++/13/tuple:1878:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::tuple<_UTypes ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
In file included from /usr/include/c++/13/functional:65,
from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/array:384:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(array<_Tp, _Nm>&)'
384 | get(array<_Tp, _Nm>& __arr) noexcept
| ^~~
/usr/include/c++/13/array:384:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'std::array<_Tp, _Nm>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/array:393:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(array<_Tp, _Nm>&&)'
393 | get(array<_Tp, _Nm>&& __arr) noexcept
| ^~~
/usr/include/c++/13/array:393:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'std::array<_Tp, _Nm>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/array:402:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const array<_Tp, _Nm>&)'
402 | get(const array<_Tp, _Nm>& __arr) noexcept
| ^~~
/usr/include/c++/13/array:402:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::array<_Tp, _Nm>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/array:411:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const array<_Tp, _Nm>&&)'
411 | get(const array<_Tp, _Nm>&& __arr) noexcept
| ^~~
/usr/include/c++/13/array:411:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::array<_Tp, _Nm>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:80:
/usr/include/c++/13/variant:1711:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(variant<_Types ...>&)'
1711 | get(variant<_Types...>& __v)
| ^~~
/usr/include/c++/13/variant:1711:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'std::variant<_Types ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/variant:1722:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >&& std::get(variant<_Types ...>&&)'
1722 | get(variant<_Types...>&& __v)
| ^~~
/usr/include/c++/13/variant:1722:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'std::variant<_Types ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/variant:1733:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(const variant<_Types ...>&)'
1733 | get(const variant<_Types...>& __v)
| ^~~
/usr/include/c++/13/variant:1733:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::variant<_Types ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/variant:1744:5: note: candidate: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >&& std::get(const variant<_Types ...>&&)'
1744 | get(const variant<_Types...>&& __v)
| ^~~
/usr/include/c++/13/variant:1744:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::variant<_Types ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/variant:1150:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(variant<_Types ...>&)'
1150 | get(variant<_Types...>& __v)
| ^~~
/usr/include/c++/13/variant:1150:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'std::variant<_Types ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/variant:1160:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(variant<_Types ...>&&)'
1160 | get(variant<_Types...>&& __v)
| ^~~
/usr/include/c++/13/variant:1160:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'std::variant<_Types ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/variant:1170:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const variant<_Types ...>&)'
1170 | get(const variant<_Types...>& __v)
| ^~~
/usr/include/c++/13/variant:1170:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::variant<_Types ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~
/usr/include/c++/13/variant:1180:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const variant<_Types ...>&&)'
1180 | get(const variant<_Types...>&& __v)
| ^~~
/usr/include/c++/13/variant:1180:5: note: template argument deduction/substitution failed:
supertrees.cpp:18:42: note: mismatched types 'const std::variant<_Types ...>' and 'int'
18 | return (par2[x]==x)?x:par2[x]=get(par2[x]);
| ~~~^~~~~~~~~