Submission #316016

#TimeUsernameProblemLanguageResultExecution timeMemory
316016katearimaConnecting Supertrees (IOI20_supertrees)C++14
100 / 100
255 ms22364 KiB
#include "supertrees.h" #include <vector> #include <bits/stdc++.h> using namespace std; int i,j; int construct(vector<vector<int> > p) { int n = p.size(); vector<vector<int> > ans; vector<int> v; v.resize(n); for (int i = 0; i < n; i++) { ans.push_back(v); } for(i=0; i<n; i++){ for(j=0; j<n; j++){ if(p[i][j]==3) return 0; if(p[i][j]!=p[j][i]) return 0; } } bool C=false; vector<int> num(n); vector<int> f(n,-1); v.clear(); for(i=0; i<n; i++){ if(f[i]>=0) continue; for(j=0; j<n; j++){ if(p[i][j]==1) { if(f[j]>=0) return 0;; v.push_back(j); f[j]=i; } } for(int k=0; k<v.size()-1; k++){ int a=v[k]; int b=v[k+1]; ans[a][b]=ans[b][a]=1; } v.clear(); } v.clear(); vector<int> z(n,-1); for(i=0;i<n; i++){ if(z[i]>=0) continue; for(j=0; j<n; j++){ if(p[i][j]>0){ if(z[j]>=0) return 0; z[j]=i; if(p[i][j]==2&& f[j]==j) {v.push_back(j); C=true;} } } v.push_back(i); if(v.size()==2) return 0; if(v.size()!=1){ for(int k=0; k<v.size(); k++){ int a=v[k]; int b=v[(k+1)%v.size()]; ans[a][b]=ans[b][a]=1; } } v.clear(); } for(i=0; i<n; i++){ for(j=0;j<n; j++){ if(i==j) continue; if(f[i]==f[j]){ if(p[i][j]!=1) return 0; } else if(z[i]==z[j]){ if(p[i][j]!=2 && C==true) return 0; } else{ if(p[i][j]!=0) return 0; } } } build(ans); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:33:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   for(int k=0; k<v.size()-1; k++){
      |                ~^~~~~~~~~~~
supertrees.cpp:53:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |          for(int k=0; k<v.size(); k++){
      |                       ~^~~~~~~~~
#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...