Submission #318346

#TimeUsernameProblemLanguageResultExecution timeMemory
318346NintsiChkhaidzeConnecting Supertrees (IOI20_supertrees)C++14
21 / 100
276 ms23136 KiB
#include "supertrees.h" #include <iostream> #include <vector> #define pb push_back using namespace std; vector<vector<int>> answer; vector <int> row,vec[1005],k; int par[1005]; bool f[1005]; int construct(vector<vector<int>> p) { int n = p.size(); for(int i=0;i<n;i++){ row.clear(); for (int j=0;j<n;j++){ if (p[i][j] == 3) return 0; if (p[i][i] != 1) return 0; row.pb(0); } answer.pb(row); } for(int i=0;i<n;i++) par[i]=i; for (int i=0;i<n;i++){ if (f[i]) continue; for (int j=0;j<n;j++){ if (p[i][j] == 1 && i!=j){ vec[i].pb(j); f[j]=1; par[j] = i; answer[i][j]=answer[j][i]=1; } } } for(int i=0;i<n;i++) f[i]=0; for (int i=0;i<n;i++) for (int j=0;j<vec[i].size();j++) if (p[i][vec[i][j]] != 1) return 0; for (int i=0;i<n;i++){ for (int j=0;j<n;j++){ if (par[i] == par[j] && p[i][j] != 1) return 0; if (par[i] != par[j] && p[i][j] != 0) return 0; } } for(int i=0;i<n;i++){ if(f[i]) continue; row.clear(); for (int j=0;j<n;j++) if (p[i][j] == 2) f[j] = 1,row.pb(j); int st = i,cur = i; k.clear(); k.pb(i); for (int j=0;j<row.size();j++){ k.pb(row[j]); answer[row[j]][cur] = answer[cur][row[j]] = 1; cur = row[j]; } if (row.size()==0) continue; if (row.size() == 1) {return 0;} for (int j=0;j<k.size();j++){ for (int u = j+1;u<k.size();u++) if (p[k[j]][k[u]] != 2) {return 0;} } int last = row[row.size() - 1]; answer[st][last] = answer[last][st] = 1; } build(answer); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:36:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for (int j=0;j<vec[i].size();j++)
      |                      ~^~~~~~~~~~~~~~
supertrees.cpp:54:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for (int j=0;j<row.size();j++){
      |                      ~^~~~~~~~~~~
supertrees.cpp:61:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for (int j=0;j<k.size();j++){
      |                      ~^~~~~~~~~
supertrees.cpp:62:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |             for (int u = j+1;u<k.size();u++)
      |                              ~^~~~~~~~~
#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...