Submission #1000328

#TimeUsernameProblemLanguageResultExecution timeMemory
1000328codefoxConnecting Supertrees (IOI20_supertrees)C++14
100 / 100
156 ms24148 KiB
#include<bits/stdc++.h> #include "supertrees.h" using namespace std; int construct(std::vector<std::vector<int>> p) { int n = p.size(); vector<int> rep(n); iota(rep.begin(), rep.end(), 0); vector<vector<int>> b(n, vector<int>(n)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (p[i][j]==3) return 0; } } for (int i = 0; i < n; i++) { if (rep[i]!=i) continue; for (int j = i+1; j < n; j++) { if (p[i][j]!=1) continue; for (int k = 0; k < n; k++) { if (p[i][k]!=p[j][k]) return 0; } b[i][j] = 1; b[j][i] = 1; rep[j] = i; } } vector<int> vis(n,0); for (int i = 0; i < n; i++) { if (rep[i]!=i) continue; if (vis[i]) continue; vector<int> cyc; cyc.push_back(i); for (int j = i+1; j < n; j++) { if (p[i][j]!=2) continue; if (rep[j]!=j) continue; for (int k = 0; k < n; k++) { if (p[i][k]==1 && rep[k]==i && p[j][k]==2) continue; if (p[i][k]==2 && p[j][k]==1 && rep[k]==j) continue; if (p[i][k]==2 && p[j][k]==2) continue; if (p[i][k]==0 && p[j][k]==0) continue; return 0; } vis[j] = 1; cyc.push_back(j); } if (cyc.size()==1) continue; if (cyc.size()==2) return 0; for (int j = 0; j < cyc.size()-1; j++) { b[cyc[j]][cyc[j+1]] = 1; b[cyc[j+1]][cyc[j]] = 1; } b[i][cyc.back()] = 1; b[cyc.back()][i] = 1; } build(b); return 1; return 0; }

Compilation message (stderr)

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