제출 #424443

#제출 시각아이디문제언어결과실행 시간메모리
424443MrFrancho슈퍼트리 잇기 (IOI20_supertrees)C++14
0 / 100
1 ms412 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1000; vector<vector<int>> connectedGroups; vector<bool> vis(MAXN); int n; void DFS(int node, int cur, vector<vector<int>> &p) { connectedGroups[cur].push_back(node); vis[node] = true; for(int i = 0; i < n; i++) { if(p[node][i] == 1 && !vis[i]) DFS(i,cur,p); } } int construct(vector<vector<int>> p) { n = p.size(); vector<vector<int>> answer; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { answer[i][j] = 0; for(int k = 0; k < n; k++) { if(p[i][k] == 1 && p[j][k] == 1 && p[i][j] != 1) return 0; } } } int c = 0; for (int i = 0; i < n; i++) { if(!vis[i]) { DFS(i,c,p); c++; } } for(auto v : connectedGroups) { for(int i = 1; i < (int)v.size(); i++) { answer[v[0]][v[i]] = 1; } } 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...