제출 #403943

#제출 시각아이디문제언어결과실행 시간메모리
403943monus1042슈퍼트리 잇기 (IOI20_supertrees)C++17
21 / 100
300 ms24052 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; const int NAX = 1002; vector<int> parent(NAX, -1); int Find(int u){ if (parent[u] == -1) return u; return parent[u] = Find(parent[u]); } int construct(vector<vector<int> > p) { int n = p.size(); vector<vector<int> > answer; for (int i = 0; i < n; i++) { vector<int> row; row.resize(n); answer.push_back(row); } // solve: for (int i=0; i<n; i++){ for (int j=0; j<n; j++){ if (i==j) continue; if (p[i][j] == 1){ int x = Find(i), y = Find(j); if (x!=y){ parent[x]=y; answer[i][j]=answer[j][i]=1; } } } } for (int i=0; i<n; i++){ for (int j=0; j<n; j++){ if (i==j) continue; int x = Find(i), y = Find(j); if (p[i][j] == 1){ if (x!=y) return 0; }else{ if (x==y) return 0; } } } 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...