제출 #431905

#제출 시각아이디문제언어결과실행 시간메모리
431905MOUF_MAHMALAT슈퍼트리 잇기 (IOI20_supertrees)C++14
컴파일 에러
0 ms0 KiB
#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
vector<vector<ll> >ans,v,w;
vector<pair<ll,ll> >op;
ll n,p1[1009],p2[1009];
ll gp1(ll z)
{
    if(p1[z]==z)
        return z;
    return p1[z]=gp1(p1[z]);
}
ll gp2(ll z)
{
    if(p2[z]==z)
        return z;
    return p2[z]=gp2(p2[z]);
}
void mrg1(ll x,ll y)
{
    x=gp1(x),y=gp1(y);
    if(x==y)
        return;
    if(v[y].size()>v[x].size())
        swap(x,y);
    p1[y]=x;
    for(auto z:v[y])
        v[x].push_back(z);
}
void mrg2(ll x,ll y)
{
    x=gp2(x),y=gp2(y);
    if(x==y)
        return;
    if(w[y].size()>w[x].size())
        swap(x,y);
    p2[y]=x;
    for(auto z:w[y])
        w[x].push_back(z);
}
int construct(vector<vector<int> > pp)
{
    n=pp.size();
    v.resize(n);
    w.resize(n);
    ans.resize(n);

    for(ll i=0; i<n; i++)
        ans[i].resize(n);

    for(ll i=0; i<n; i++)
        p1[i]=p2[i]=i,w[i].push_back(i),v[i]=w[i];

    for(ll i=0; i<n; i++)
        for(ll j=0; j<n; j++)
        {
            if(i==j)
                continue;
            if(pp[i][j]==3)
                return 0;
            if(pp[i][j]==1)
                mrg1(i,j);
            else if(pp[i][j]==2)
                mrg2(i,j);
        }

    for(ll i=0; i<n; i++)
    {
        if(p1[i]!=i)
            continue;
        for(ll j=1; j<v[i].size(); j++)
            ans[i][v[i][j]]=ans[v[i][j]][i]=1;
    }
    for(ll i=0;i<n;i++)
    {
        if(p2[i]!=i)
            continue;
        for(ll j=1;j<w[i].size()-1;j++)
            ans[w[i][j]][w[i][j+1]]=ans[w[i][j+1]][w[i][j]]=1;
        ans[w[i][0]][w.back()]=ans[w.back()][w[i][0]]=1;
    }
    for(ll i=0;i<n;i++)
    for(ll j=0;j<n;j++)
    {
        if(i==j)
            continue;
        ll x=gp1(i),y=gp1(j);
        if(x==y&&pp[i][j]!=1)
            return 0;
        ll xx=gp2(i),yy=gp2(j);
        if(xx==yy&&pp[i][j]==0)
            return 0;
    }
    build(ans);
    return 1;
}

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:72:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |         for(ll j=1; j<v[i].size(); j++)
      |                     ~^~~~~~~~~~~~
supertrees.cpp:79:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |         for(ll j=1;j<w[i].size()-1;j++)
      |                    ~^~~~~~~~~~~~~~
supertrees.cpp:81:21: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} and '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'})
   81 |         ans[w[i][0]][w.back()]=ans[w.back()][w[i][0]]=1;
      |                     ^
In file included from /usr/include/c++/10/vector:67,
                 from supertrees.h:1,
                 from supertrees.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
supertrees.cpp:81:35: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<int> >' and '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'})
   81 |         ans[w[i][0]][w.back()]=ans[w.back()][w[i][0]]=1;
      |                                   ^
In file included from /usr/include/c++/10/vector:67,
                 from supertrees.h:1,
                 from supertrees.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::reference = std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::const_reference = const std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~