Submission #315842

#TimeUsernameProblemLanguageResultExecution timeMemory
315842katearimaConnecting Supertrees (IOI20_supertrees)C++14
0 / 100
1 ms256 KiB
#include "supertrees.h" #include <iostream> #include <bits/stdc++.h> #include <vector> using namespace std; vector< vector<int> > c,p,t,ans; vector<int> v; int i,j,k; int construct(vector<vector<int>> p) { int n = p.size(); vector<vector<int>> ans; 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; } } v.resize(n); for(i=0; i<n; i++) ans.push_back(v); v.clear(); vector<int> f(n); for(i=0; i<n; i++){ bool InCycle=false; if(f[i]==1) continue; for(j=0; j<n; j++){ if(p[i][j]==1) { if(f[j]==1) return 0;; v.push_back(j); f[j]=1; } if(p[i][j]==2) InCycle=true; } for(k=0; k<v.size()-1; k++){ ans[i][i+1]=ans[i+1][i]=1; } if(InCycle) c.push_back(v); v.clear(); } vector<int> z(n); for(i=0;i<n; i++){ if(z[i]==1) continue; for(j=0; j<n; j++){ if(p[i][j]==0){ if(z[i]==1) return 0; z[i]=1; } } } if(c.size()==2) return 0; k=c.size(); if(k!=1){ for(i=0; i<k; i++){ int a=c[i][0]; int b=c[(i+1)%k][0]; ans[a][b]=ans[b][a]=1; } } build(ans); return 1; }

Compilation message (stderr)

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