Submission #888213

#TimeUsernameProblemLanguageResultExecution timeMemory
88821312345678Connecting Supertrees (IOI20_supertrees)C++17
0 / 100
162 ms22092 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; const int nx=1e3+5; bool vs[nx]; int construct(std::vector<std::vector<int>> p) { int n = p.size(); vector<vector<int>> answer(n, vector<int> (n, 0)); for (int i=0; i<n; i++) { if (vs[i]) continue; queue<int> q; vector<int> d; q.push(i); vs[i]=1; while (!q.empty()) { auto u=q.front(); q.pop(); d.push_back(u); for (int v=0; v<n; v++) if (p[u][v]==2&&!vs[v]) vs[v]=1, q.push(v); } for (auto u:d) for (auto v:d) if (p[u][v]==0) return 0; if (d.size()==2) return 0; if (d.size()<=1) continue; int sz=d.size(); for (int j=0; j<sz-1; j++) answer[d[j]][d[j+1]]=answer[d[j+1]][d[j]]=1; answer[d[0]][d[sz-1]]=answer[d[d[sz-1]]][d[0]]=1; } build(answer); return 1; } /* 4 1 2 2 0 2 1 2 0 2 2 1 0 0 0 0 1 4 1 2 0 0 2 1 0 0 0 0 1 0 0 0 0 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...