#include <bits/stdc++.h>
#include "supertrees.h"
using namespace std;
#define pb push_back
const int N = 1005;
int a[N][N], o;
bool vis[N];
vector <int> v[N];
void dfs (int x, int pr) {
if (pr != -1) {
a[pr][x] = a[x][pr] = 1;
}
vis[x] = o;
for (int i : v[x]) {
if (vis[i]) continue;
dfs (i, x);
}
}
int construct(vector<vector<int>> p) {
int n = p.size();
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (i == j) continue;
if (p[i][j]) {
v[i].pb (j);
}
}
}
for (int i = 0; i < n; ++i) {
if (!vis[i]) {
o++;
dfs (i, -1);
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (i == j) continue;
if ((p[i][j] == 1) and (vis[i] != vis[j])) return 0;
if (p[i][j] == 0 and vis[i] == vis[j]) return 0;
}
}
vector<vector<int>> answer;
for (int i = 0; i < n; i++) {
vector<int> row;
row.resize(n);
for (int j = 0; j < n; ++j) {
if (a[i][j]) row[j] = 1;
}
answer.push_back(row);
}
build(answer);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
336 KB |
Output is correct |
6 |
Correct |
7 ms |
2264 KB |
Output is correct |
7 |
Correct |
165 ms |
31964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
336 KB |
Output is correct |
6 |
Correct |
7 ms |
2264 KB |
Output is correct |
7 |
Correct |
165 ms |
31964 KB |
Output is correct |
8 |
Incorrect |
0 ms |
340 KB |
Answer gives possible 0 while actual possible 1 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
336 KB |
Answer gives possible 0 while actual possible 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Answer gives possible 0 while actual possible 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
336 KB |
Output is correct |
6 |
Correct |
7 ms |
2264 KB |
Output is correct |
7 |
Correct |
165 ms |
31964 KB |
Output is correct |
8 |
Incorrect |
0 ms |
340 KB |
Answer gives possible 0 while actual possible 1 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
336 KB |
Output is correct |
6 |
Correct |
7 ms |
2264 KB |
Output is correct |
7 |
Correct |
165 ms |
31964 KB |
Output is correct |
8 |
Incorrect |
0 ms |
340 KB |
Answer gives possible 0 while actual possible 1 |
9 |
Halted |
0 ms |
0 KB |
- |