Submission #651875

#TimeUsernameProblemLanguageResultExecution timeMemory
651875coding_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 0; } if (Rank[A1]>Rank[A2]) Boss[A2]=A1; else if(Rank[A1]<Rank[A2]) Boss[A1]=A2; else{ Boss[A2]=A1; Rank[A1]++; } return 1; } 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 OK_List[1000]={1}; for(int i=0;i<x.size();i++){ int now_check=Boss[i]; vector<int> List1={i}; if(OK_List[i]){ OK_List[i]=0; for(int j=0;j<x.size();j++){ if(i!=j && now_check==Boss[j]){ List1.push_back(j); OK_List[j]=0; } } } List1.push_back(i); if(List1.size()>3){ for(int k=0;k<List1.size()-1;k++){ built[List1[k]][List1[k+1]]=1; built[List1[k+1]][List1[k]]=1; } } } int answer=1; for(int i=0;i<x.size();i++){ for(int j=i+1;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:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i=0;i<x.size();i++){
      |                 ~^~~~~~~~~
supertrees.cpp:32:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   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:52:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(int i=0;i<x.size();i++){
      |                 ~^~~~~~~~~
supertrees.cpp:57:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |             for(int j=0;j<x.size();j++){
      |                         ~^~~~~~~~~
supertrees.cpp:66:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |         for(int k=0;k<List1.size()-1;k++){
      |                     ~^~~~~~~~~~~~~~~
supertrees.cpp:73:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |     for(int i=0;i<x.size();i++){
      |                 ~^~~~~~~~~
supertrees.cpp:74:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |         for(int j=i+1;j<x.size();j++){
      |                       ~^~~~~~~~~
supertrees.cpp:81:16: error: 'build' was not declared in this scope; did you mean 'built'?
   81 |     if(answer) build(built);
      |                ^~~~~
      |                built