Submission #384654

#TimeUsernameProblemLanguageResultExecution timeMemory
384654nicholaskConnecting Supertrees (IOI20_supertrees)C++14
46 / 100
298 ms24172 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; int construct(vector <vector <int> > p){ int n=p.size(); vector <vector <int> > ans(n,vector<int>(n,0)); vector <vector <int> > ones; bool d[n]; for (int i=0; i<n; i++) d[i]=0; for (int i=0; i<n; i++){ if (d[i]) continue; vector <int> v; for (int j=i; j<n; j++){ if (p[i][j]==1){ if (d[j]) return 0; d[j]=1; v.push_back(j); } } for (int j=0; j<v.size()-1; j++) ans[v[j]][v[j+1]]=1; ones.push_back(v); } bool e[ones.size()]; for (int i=0; i<ones.size(); i++) e[i]=0; for (int i=0; i<ones.size(); i++){ if (e[i]) continue; vector <int> temp; temp.push_back(ones[i].front()); for (int j=i+1; j<ones.size(); j++){ if (!e[j]&&p[ones[i].front()][ones[j].front()]==2){ temp.push_back(ones[j].front()); e[j]=1; } } int ss=temp.size(); if (ss<3) continue; for (int j=0; j<temp.size(); j++) ans[temp[j]][temp[(j+1)%ss]]=1; } for (int i=0; i<n; i++){ for (int j=0; j<n; j++){ if (ans[j][i]) ans[i][j]=1; } } build(ans); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for (int j=0; j<v.size()-1; j++) ans[v[j]][v[j+1]]=1;
      |                 ~^~~~~~~~~~~
supertrees.cpp:24:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for (int i=0; i<ones.size(); i++) e[i]=0;
      |                ~^~~~~~~~~~~~
supertrees.cpp:25:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for (int i=0; i<ones.size(); i++){
      |                ~^~~~~~~~~~~~
supertrees.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   for (int j=i+1; j<ones.size(); j++){
      |                   ~^~~~~~~~~~~~
supertrees.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   for (int j=0; j<temp.size(); j++) ans[temp[j]][temp[(j+1)%ss]]=1;
      |                 ~^~~~~~~~~~~~
#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...