Submission #1108740

#TimeUsernameProblemLanguageResultExecution timeMemory
1108740SteveBroConnecting Supertrees (IOI20_supertrees)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "supertrees.h" using namespace std; int n,mat[1001][1001]; int sef[1001]; int ef(int x) { if(sef[x]==x) return x; else return sef[x]=ef(sef[x]); } vector <int> comp[1001],rez; bool ok[1001]; int construct(int p[][1001]) { int i,j,nr; for(i=0;i<n;i++) sef[i]=i; for(i=0;i<n;i++) { for(j=0,nr=0;j<n;j++) { if(p[i][j]==3) return 0; if(p[i][j]==0&&ef(i)==ef(j)) return 0; if(p[i][j]>0) sef[ef(i)]=ef(j); if(p[i][j]==2) nr++; if(p[i][j]==1&&i!=j) ok[i]=true; } if(nr==1) return 0; } for(i=0;i<n;i++) comp[ef(i)].push_back(i); for(i=0;i<n;i++) sef[i]=-1; for(i=0;i<n;i++) { if(!comp[i].empty()) { rez.clear(); for(auto x : comp[i]) { if(!ok[x])/// se alfa pe ciclu rez.push_back(x); else { if(sef[x]==-1)///nou lant { rez.push_back(x); sef[x]=x; for(j=0;j<n;j++) { if(p[x][j]==1&&x!=j) { if(sef[j]==-1) { sef[j]=x; mat[x][j]=mat[j][x]=1; } else return 0; } } } else { for(j=0;j<n;j++) { if(p[x][j]==2&&sef[x]==sef[j]) return 0; if(p[x][j]==1&&sef[x]!=sef[j]) return 0; } } } } if(rez.size()>2) { for(j=1;j<rez.size();j++) { mat[rez[j-1]][rez[j]]=mat[rez[j]][rez[j-1]]=1; } mat[rez[0]][rez[j-1]]=mat[rez[j-1]][rez[0]]=1; } } } build(mat); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(int (*)[1001])':
supertrees.cpp:85:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |                 for(j=1;j<rez.size();j++)
      |                         ~^~~~~~~~~~~
supertrees.cpp:93:11: error: could not convert '(int (*)[1001])(& mat)' from 'int (*)[1001]' to 'std::vector<std::vector<int> >'
   93 |     build(mat);
      |           ^~~
      |           |
      |           int (*)[1001]