Submission #651832

#TimeUsernameProblemLanguageResultExecution timeMemory
651832coding_snorlaxConnecting Supertrees (IOI20_supertrees)C++14
Compilation error
0 ms0 KiB
#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;
int Boss[1005];
int Rank[1005];
int query(int x){
    if(Boss[x]==x) return x;
    else return Boss[x]=query(Boss[x]);
}
int Union(int x,int y){
    int A1=query(x);
    int A2=query(y);
    if(A1==A2){
        return 1;
    }
    if (Rank[A1]>Rank[A2]) Boss[A2]=A1;
    else if(Rank[A1]<Rank[A2]) Boss[A1]=A2;
    else{
        Boss[A2]=A1;
        Rank[A1]++;
    }
    return 0;
}
int construct(vector<vector<int>> x){
    for(int i=0;i<1005;i++){
        Boss[i]=i;
        Rank[i]=0;
    }
    vector<vector<int>> built;
    for(int i=0;i<x.size;i++){
        vector<int> New;
        for(int j=0;j<x.size;j++){
            New.push_back(0);
        }
        built.push_back(New);
    }
    int check=0;
    for(int i=0;i<x.size();i++){
        for(int j=0;j<x.size();j++){
            if (x[i][j]){
                check=Union(i,j);
                if(check && i!=j){
                    built[i][j]=1;
                    built[j][i]=1;
                }
            }
        }
    }
    int answer=1;
    for(int i=0;i<x.size();i++){
        for(int j=0;j<x.size();j++){
            if ((x[i][j] && query(i)!=query(j)) || (!x[i][j] && query(i)==query(j))){
                answer=0;
            }
        }
    }
    if(answer) build(built);
    return answer;
}

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:30:21: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' (did you forget the '()' ?)
   30 |     for(int i=0;i<x.size;i++){
      |                   ~~^~~~
      |                         ()
supertrees.cpp:32:25: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' (did you forget the '()' ?)
   32 |         for(int j=0;j<x.size;j++){
      |                       ~~^~~~
      |                             ()
supertrees.cpp:38:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i=0;i<x.size();i++){
      |                 ~^~~~~~~~~
supertrees.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int j=0;j<x.size();j++){
      |                     ~^~~~~~~~~
supertrees.cpp:50:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i=0;i<x.size();i++){
      |                 ~^~~~~~~~~
supertrees.cpp:51:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         for(int j=0;j<x.size();j++){
      |                     ~^~~~~~~~~