#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] and i!=j){
A[i].push_back(j);
ans[i][j]=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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Answer gives possible 0 while actual possible 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Answer gives possible 0 while actual possible 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
7 ms |
1372 KB |
Output is correct |
9 |
Correct |
118 ms |
23932 KB |
Output is correct |
10 |
Incorrect |
0 ms |
348 KB |
Answer gives possible 0 while actual possible 1 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Answer gives possible 0 while actual possible 1 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Answer gives possible 0 while actual possible 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Answer gives possible 0 while actual possible 1 |
3 |
Halted |
0 ms |
0 KB |
- |