제출 #568419

#제출 시각아이디문제언어결과실행 시간메모리
568419Jomnoi슈퍼트리 잇기 (IOI20_supertrees)C++17
0 / 100
1 ms352 KiB
#include <bits/stdc++.h> #include "supertrees.h" using namespace std; const int MAX_N = 1e3 + 5; int n; int parent[MAX_N]; vector <vector <int>> answer; vector <int> graph[MAX_N]; bool visited[MAX_N]; bool ok; vector <int> nodes[MAX_N]; int root(int u) { if(u == parent[u]) { return u; } return parent[u] = root(parent[u]); } int construct(vector <vector <int>> p) { n = p.size(); fill(visited, visited + n, false); answer.resize(n, vector <int> (n, 0)); iota(parent, parent + n, 0); for(int i = 0; i < n; i++) { for(int j = i + 1; j < n; j++) { if(p[i][j] == 2) { parent[root(j)] = root(i); } } } for(int i = 0; i < n; i++) { for(int j = i + 1; j < n; j++) { if(p[i][j] == 0 and root(i) == root(j)) { return 0; } } } for(int i = 0; i < n; i++) { nodes[root(i)].push_back(i); } for(int i = 0; i < n; i++) { if(i == root(i)) { int p = nodes[i].back(); for(auto v : nodes[i]) { answer[p][v] = answer[v][p] = 1; p = v; } } } build(answer); return 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...