Submission #309461

#TimeUsernameProblemLanguageResultExecution timeMemory
309461pere_gilConnecting Supertrees (IOI20_supertrees)C++17
0 / 100
1 ms384 KiB
#include "bits/stdc++.h" #include "supertrees.h" using namespace std; int pos[1001]; void init(int n){ for(int i=0;i<n;i++) pos[i]=i; } int findset(int a){ if(pos[a]==a) return a; else return pos[a]=findset(pos[a]); } void unionset(int A, int B){ int a=findset(A); int b=findset(B); if(a!=b) pos[b]=a; } bool issameset(int a, int b){ if(findset(a)==findset(b)) return true; else return false; } int construct(std::vector<std::vector<int> > p) { int n = p.size(); std::vector<std::vector<int> > answer; init(n); for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(p[i][j]==1) unionset(i,j); } } vector<int> ja[n]; for(int i=0;i<n;i++) ja[findset(i)].push_back(i); bool semamo=false; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(issameset(i,j) and p[i][j]==0) semamo=true; } } if(semamo) return 0; int res[n][n]; memset(res,0,sizeof(res)); for(int i=0;i<n;i++){ for(int j=0;j<ja[i].size()-2;j++){ res[ja[i][j]][ja[i][j+1]]=1; res[ja[i][j+1]][ja[i][j]]=1; } } for (int i = 0; i < n; i++) { std::vector<int> row; for(int j=0;j<n;j++) row.push_back(res[i][j]); row.resize(n); answer.push_back(row); } build(answer); return 1; return 0; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:55:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for(int j=0;j<ja[i].size()-2;j++){
      |                     ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...