#include "supertrees.h"
#include <vector>
#include <iostream>
#define ll long long
#define pb push_back
using namespace std;
const int N = 2005;
vector<int> gr[N];
int used[N], d[N], sz[N];
vector<vector<int>> ans;
int get_parent(int v){
while(v != d[v])
v = d[v];
return v;
}
void add(int u, int v){
//cout << "Add " << u << ' ' << v << endl;
int f = get_parent(u), s = get_parent(v);
//cout << "Parents " << f << ' ' << s << endl;
if(f != s){
ans[f][s] = ans[s][f] = 1;
if(sz[s] < sz[f]){
d[s] = f;
sz[s] += sz[f];
sz[f] = 0;
}
else{
d[f] = s;
sz[f] += sz[s];
sz[s] = 0;
}
}
}
int construct(std::vector<std::vector<int>> p) {
int n = p.size();
int fault = 0;
for(int i = 0; i < n; i++){
d[i] = i;
sz[i] = 1;
}
for(int i = 0; i < n; i++){
ans.pb({});
for(int j = 0; j < n; j++)
ans[i].pb(0);
}
for(int i = 0; i < n; i++){
for(int j = i; j < n; j++){
if(p[i][j] != p[j][i])
fault++;
else if(i == j && p[i][j] != 1)
fault++;
if(p[i][j] && i != j){
add(i, j);
gr[i].pb(j);
gr[j].pb(i);
}
}
}
/*for(int i = 0; i < n; i++){
if(!used[i])
dfs(i);
}*/
build(ans);
return 1;
}
/*
5
1 0 0 1 1
0 1 1 0 0
0 1 1 0 0
1 0 0 1 1
1 0 0 1 1
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
21 ms |
1536 KB |
Output is correct |
7 |
Execution timed out |
1088 ms |
15520 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
21 ms |
1536 KB |
Output is correct |
7 |
Execution timed out |
1088 ms |
15520 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Incorrect |
1 ms |
384 KB |
Answer gives possible 1 while actual possible 0 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Too few ways to get from 0 to 1, should be 2 found 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
21 ms |
1536 KB |
Output is correct |
7 |
Execution timed out |
1088 ms |
15520 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
21 ms |
1536 KB |
Output is correct |
7 |
Execution timed out |
1088 ms |
15520 KB |
Time limit exceeded |