#include<bits/stdc++.h>
#include "supertrees.h"
using namespace std;
vector < int > adj[1002];
int ataman[10002];
int Get(int x) {
if ( x == ataman[x]) return x;
return ataman[x] = Get(ataman[x]);
}
void Unite(int x, int y) {
x = Get(x);
y = Get(y);
if (x == y) return ;
ataman[x]= y;
}
int construct(vector<vector<int>> a) {
int n = a.size(), i, j;
vector < vector < int > > ans(n, vector<int>(n, 0));
for (i = 0; i < n; i ++) ataman[i]= i;
int s = 1;
for ( i = 0; i < n; i++) {
for ( j = 0; j < n; j ++) {
if ( a[i][j] != 0 && i != j) Unite(i, j);
}
}
for (i = 0; i < n; i ++) {
for (j = 0; j < n; j ++) {
if ( i == j) continue;
if ( a[i][j] == 0 && Get(i) == Get(j)) s= 0;
if ( a[i][j] != 0 && Get(i) != Get(j)) s = 0;
}
}
build(ans);
return s;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Too few ways to get from 0 to 1, should be 1 found 0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Too few ways to get from 0 to 1, should be 1 found 0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Answer gives possible 1 while actual possible 0 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Too few ways to get from 0 to 1, should be 2 found 0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Too few ways to get from 0 to 1, should be 1 found 0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Too few ways to get from 0 to 1, should be 1 found 0 |
3 |
Halted |
0 ms |
0 KB |
- |