#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
int construct(std::vector<std::vector<int>> p) {
int n = p.size();
vector<vector<int>> adj(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) if (p[i][j]) {
adj[i].push_back(j);
adj[j].push_back(i);
}
}
vector<int> cc;
vector<bool> vis(n);
function<void(int)> dfs = [&](int u) {
vis[u] = true;
cc.push_back(u);
for (int to : adj[u]) if (!vis[to]) {
dfs(to);
}
};
vector<vector<int>> answer(n, vector<int>(n));
for (int i = 0; i < n; i++) {
if (!vis[i]) {
dfs(i);
int m = cc.size();
int edges = 0;
for (int p : cc)
edges += adj[p].size();
edges /= 2;
// if (edges >= m)
// return 0;
for (int j = 0; j < m - 1; j++)
answer[cc[j]][cc[j + 1]] = answer[cc[j + 1]][cc[j]] = 1;
cc.clear();
}
}
build(answer);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
11 ms |
1664 KB |
Output is correct |
7 |
Correct |
265 ms |
30328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
11 ms |
1664 KB |
Output is correct |
7 |
Correct |
265 ms |
30328 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
256 KB |
Output is correct |
12 |
Correct |
10 ms |
1280 KB |
Output is correct |
13 |
Correct |
266 ms |
22136 KB |
Output is correct |
14 |
Incorrect |
1 ms |
256 KB |
Answer gives possible 1 while actual possible 0 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Incorrect |
1 ms |
256 KB |
Answer gives possible 1 while actual possible 0 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Incorrect |
1 ms |
256 KB |
Too few ways to get from 0 to 1, should be 2 found 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
11 ms |
1664 KB |
Output is correct |
7 |
Correct |
265 ms |
30328 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
256 KB |
Output is correct |
12 |
Correct |
10 ms |
1280 KB |
Output is correct |
13 |
Correct |
266 ms |
22136 KB |
Output is correct |
14 |
Incorrect |
1 ms |
256 KB |
Answer gives possible 1 while actual possible 0 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
11 ms |
1664 KB |
Output is correct |
7 |
Correct |
265 ms |
30328 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
256 KB |
Output is correct |
12 |
Correct |
10 ms |
1280 KB |
Output is correct |
13 |
Correct |
266 ms |
22136 KB |
Output is correct |
14 |
Incorrect |
1 ms |
256 KB |
Answer gives possible 1 while actual possible 0 |
15 |
Halted |
0 ms |
0 KB |
- |