이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <vector>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define ln "\n"
#define pll pair<ll, ll>
struct DSU{
vector<ll> p;
ll n;
DSU(ll N){
n=N;
p.resize(n, -1);
}
ll get(ll x){
return p[x]==-1?x:p[x]=get(p[x]);
}
bool unite(ll a, ll b){
a=get(a);
b=get(b);
if (a==b) return 0;
p[a]=b;
return 1;
}
};
int construct(std::vector<std::vector<int>> p) {
int n = (int)p.size();
bool pos=1;
DSU tr(n);
vector<vector<int>> ans(n, vector<int>(n, 0));
vector<vector<int>> A(n);
for (int i=0; i<n; i++){
for (int j=0; j<n; j++){
if (p[i][j]){
A[i].push_back(j);
A[j].push_back(i);
ans[i][j]=ans[j][i]=1;
}
}
}
for (ll i=0; i<n; i++){
if (A[i].size()!=2 and A[i].size()!=0) pos=0;
}
if (!pos) return 0;
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... |