이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
using namespace std;
const int N = 1010;
vector<int> vc;
int pre[N];
int mrk[N];
int get(int x){
return (pre[x] == x ? x : pre[x] = get(pre[x]));
}
int construct(vector<vector<int>> p) {
int n = p.size();
for (int i = 0; i < n; i++)
pre[i] = i;
vector<vector<int> > ans;
ans.resize(n);
for (int i = 0; i < n; i++)
ans[i].resize(n);
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
if (p[i][j] > 0){
int xx = get(i);
int yy = get(j);
pre[xx] = yy;
}
for (int i = 0; i < n; i++){
if (mrk[get(i)]) continue;
mrk[get(i)] = 1;
vc.clear();
for (int j = i; j < n; j++)
if (get(j) == get(i))
vc.PB(j);
for (int it = 0; it < sz(vc); it++)
for (int jt = it + 1; jt < sz(vc); jt++)
if (p[vc[it]][vc[jt]] == 0)
return 0;
for (int it = 0; it < sz(vc); it++){
if (it > 0) ans[vc[it]][vc[it - 1]] = 1;
if (it + 1 < sz(vc)) ans[vc[it]][vc[it + 1]] = 1;
}
}
build(ans);
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |