#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include "supertrees.h"
using namespace std;
bool ok;
int tree[10002] , n;
vector<vector<int>> a;
vector <int> x[1002];
int dfs( int idx , int lab ) {
tree[idx] = lab;
for (auto i : x[idx]) {
if (tree[i] == lab) continue;
if (tree[i] == -1) {
dfs(i,lab);
}
else {
ok = false;
}
}
return 0;
}
int construct(vector<vector<int>> p) {
n = (int)p.size();
ok = true;
memset(tree,-1,sizeof(tree));
a = p;
for (int i = 0; i < (int)a.size(); i++) {
for (int j = 0; j < (int)a.size(); j++) {
if (i == j) continue;
if (p[i][j] != p[j][i] || p[i][i] != 1 ) return 0;
a[i][j] = 0;
if (p[i][j] == 1) {
x[i].push_back(j);
}
}
}
for (int i = 0; i < n; i++) {
if (tree[i] == -1) {
dfs(i,i);
if (!ok) return 0;
}
}
for (int i = 0; i < n; i++) {
a[i] = p[tree[i]];
a[i][i] = 0;
}
build(a);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Incorrect |
1 ms |
332 KB |
Too many ways to get from 0 to 2, should be 1 found no less than 2 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Incorrect |
1 ms |
332 KB |
Too many ways to get from 0 to 2, should be 1 found no less than 2 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Incorrect |
1 ms |
332 KB |
Answer gives possible 1 while actual possible 0 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
1 ms |
332 KB |
Integer element b_i_j[2] equals to 2, violates the range [0, 1] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Incorrect |
1 ms |
332 KB |
Too many ways to get from 0 to 2, should be 1 found no less than 2 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Incorrect |
1 ms |
332 KB |
Too many ways to get from 0 to 2, should be 1 found no less than 2 |
4 |
Halted |
0 ms |
0 KB |
- |