Submission #302837

#TimeUsernameProblemLanguageResultExecution timeMemory
302837nadidaditConnecting Supertrees (IOI20_supertrees)C++17
0 / 100
1 ms256 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; int n; vector<vector<int>> b; int construct(vector<std::vector<int>> p) { n = p.size(); b.resize(n); for(int i = 0; i < n; ++i) b[i].resize(n); int adit[n]; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { b[i][j]=0; adit[i]=0; } } for(int i=0;i<n;i++) { if(p[i][i]!=1) { return 0; } } for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { if(p[i][j]!=p[j][i]) { return 0; } } } for(int i=0;i<n;i++) { vector<int>check; if(adit[i]==0) { check.push_back(i); for(int j=0;j<n;j++) { if(p[i][j]==2) { if(adit[j]==1) { return 0; } check.push_back(j); } } if(check.size()>2) { for(int i=0;i<check.size()-1;i++) { b[check[i]][check[i+1]]=1; adit[check[i]]=1; b[check[i+1]][check[i]]=1; } adit[check[check.size()-1]]=1; b[0][check[check.size()-1]]=1; b[check[check.size()-1]][0]=1; for(int i=0;i<check.size();i++) { for(int j=0;j<check.size();j++) { if(p[check[i]][check[j]]!=1 || p[check[i]][check[j]]!=1) { return 0; } else { p[check[i]][check[j]]=0; p[check[j]][check[i]]=0; } } } } check.clear(); } } for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { if(i!=j && p[i][j]==2) { return 0; } } } build(b); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:57:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(int i=0;i<check.size()-1;i++)
      |                 ~^~~~~~~~~~~~~~~
supertrees.cpp:66:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |     for(int i=0;i<check.size();i++)
      |                 ~^~~~~~~~~~~~~
supertrees.cpp:68:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |      for(int j=0;j<check.size();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...