#include <bits/stdc++.h>
#include "supertrees.h"
using namespace std;
#define N 100005
#define pb push_back
vector<int> vec[N];
int construct(vector<vector<int>> p){
int n = p.size();
vector<vector<int>> b(n, vector<int>(n, 0));
vector<int> vis(n, 0), ok(n, 0);
int cnt = 0;
for (int i = 0; i < n; i++){
if (vis[i]){
if (p[i] != vec[vis[i]]) return 0;
continue;
}
cnt++;
for (int j = 0; j < n; j++){
if (p[i][j] and i != j){
if (p[i][j] == 1){
b[i][j] = b[j][i] = 1;
vis[j] = cnt;
}
}
vec[cnt].pb(p[i][j]);
}
}
for (int i = 0; i < n; i++){
if (vis[i] or ok[i]) continue;
deque<int> v;
for (int j = 0; j < n; j++){
if (p[i][j] == 2 and !vis[j]){
// if (ok[j]) return 0;
ok[j] = 1;
v.pb(j);
}
}
if (!v.size()) continue;
if (v.size() == 1) return 0;
v.push_front(i);
for (int j = 0; j < (int)v.size(); j++){
for (int k = j+1; k < (int)v.size(); k++) if (p[v[j]][v[k]] != 2) return 0;
for (int k = 0; k < n; k++){
if (p[v[j]][k] == 2 and !ok[k]) return 0;
}
}
b[v[0]][v.back()] = b[v.back()][v[0]] = 1;
for (int j = 1; j < (int)v.size(); j++){
b[v[j-1]][v[j]] = b[v[j]][v[j-1]] = 1;
}
}
// for (int i = 0; i < n; i++){
// for (int j = 0; j < n; j++) cout << b[i][j] << ' ';
// cout << '\n';
// }
build(b);
return 1;
}
// int main ()
// {
// int n;
// cin >> n;
// vector<vector<int>> p(n, vector<int>(n));
// for (int i = 0; i < n; i++){
// for (int j = 0; j < n; j++) cin >> p[i][j];
// }
// int x = construct(p);
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
1 ms |
2644 KB |
Output is correct |
6 |
Correct |
7 ms |
3540 KB |
Output is correct |
7 |
Correct |
140 ms |
24328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
1 ms |
2644 KB |
Output is correct |
6 |
Correct |
7 ms |
3540 KB |
Output is correct |
7 |
Correct |
140 ms |
24328 KB |
Output is correct |
8 |
Correct |
1 ms |
2644 KB |
Output is correct |
9 |
Correct |
1 ms |
2644 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
1 ms |
2644 KB |
Output is correct |
12 |
Correct |
7 ms |
3716 KB |
Output is correct |
13 |
Correct |
153 ms |
28352 KB |
Output is correct |
14 |
Correct |
1 ms |
2644 KB |
Output is correct |
15 |
Correct |
1 ms |
2644 KB |
Output is correct |
16 |
Correct |
4 ms |
3028 KB |
Output is correct |
17 |
Correct |
60 ms |
14384 KB |
Output is correct |
18 |
Correct |
1 ms |
2644 KB |
Output is correct |
19 |
Correct |
1 ms |
2644 KB |
Output is correct |
20 |
Correct |
37 ms |
8192 KB |
Output is correct |
21 |
Correct |
146 ms |
24388 KB |
Output is correct |
22 |
Correct |
146 ms |
25908 KB |
Output is correct |
23 |
Correct |
145 ms |
24380 KB |
Output is correct |
24 |
Correct |
150 ms |
28172 KB |
Output is correct |
25 |
Correct |
58 ms |
14412 KB |
Output is correct |
26 |
Correct |
59 ms |
15552 KB |
Output is correct |
27 |
Correct |
147 ms |
24368 KB |
Output is correct |
28 |
Correct |
148 ms |
28236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Incorrect |
1 ms |
2644 KB |
Answer gives possible 0 while actual possible 1 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2644 KB |
Answer gives possible 0 while actual possible 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
1 ms |
2644 KB |
Output is correct |
6 |
Correct |
7 ms |
3540 KB |
Output is correct |
7 |
Correct |
140 ms |
24328 KB |
Output is correct |
8 |
Correct |
1 ms |
2644 KB |
Output is correct |
9 |
Correct |
1 ms |
2644 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
1 ms |
2644 KB |
Output is correct |
12 |
Correct |
7 ms |
3716 KB |
Output is correct |
13 |
Correct |
153 ms |
28352 KB |
Output is correct |
14 |
Correct |
1 ms |
2644 KB |
Output is correct |
15 |
Correct |
1 ms |
2644 KB |
Output is correct |
16 |
Correct |
4 ms |
3028 KB |
Output is correct |
17 |
Correct |
60 ms |
14384 KB |
Output is correct |
18 |
Correct |
1 ms |
2644 KB |
Output is correct |
19 |
Correct |
1 ms |
2644 KB |
Output is correct |
20 |
Correct |
37 ms |
8192 KB |
Output is correct |
21 |
Correct |
146 ms |
24388 KB |
Output is correct |
22 |
Correct |
146 ms |
25908 KB |
Output is correct |
23 |
Correct |
145 ms |
24380 KB |
Output is correct |
24 |
Correct |
150 ms |
28172 KB |
Output is correct |
25 |
Correct |
58 ms |
14412 KB |
Output is correct |
26 |
Correct |
59 ms |
15552 KB |
Output is correct |
27 |
Correct |
147 ms |
24368 KB |
Output is correct |
28 |
Correct |
148 ms |
28236 KB |
Output is correct |
29 |
Correct |
1 ms |
2644 KB |
Output is correct |
30 |
Correct |
1 ms |
2644 KB |
Output is correct |
31 |
Correct |
1 ms |
2644 KB |
Output is correct |
32 |
Correct |
1 ms |
2644 KB |
Output is correct |
33 |
Incorrect |
1 ms |
2644 KB |
Answer gives possible 0 while actual possible 1 |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
1 ms |
2644 KB |
Output is correct |
6 |
Correct |
7 ms |
3540 KB |
Output is correct |
7 |
Correct |
140 ms |
24328 KB |
Output is correct |
8 |
Correct |
1 ms |
2644 KB |
Output is correct |
9 |
Correct |
1 ms |
2644 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
1 ms |
2644 KB |
Output is correct |
12 |
Correct |
7 ms |
3716 KB |
Output is correct |
13 |
Correct |
153 ms |
28352 KB |
Output is correct |
14 |
Correct |
1 ms |
2644 KB |
Output is correct |
15 |
Correct |
1 ms |
2644 KB |
Output is correct |
16 |
Correct |
4 ms |
3028 KB |
Output is correct |
17 |
Correct |
60 ms |
14384 KB |
Output is correct |
18 |
Correct |
1 ms |
2644 KB |
Output is correct |
19 |
Correct |
1 ms |
2644 KB |
Output is correct |
20 |
Correct |
37 ms |
8192 KB |
Output is correct |
21 |
Correct |
146 ms |
24388 KB |
Output is correct |
22 |
Correct |
146 ms |
25908 KB |
Output is correct |
23 |
Correct |
145 ms |
24380 KB |
Output is correct |
24 |
Correct |
150 ms |
28172 KB |
Output is correct |
25 |
Correct |
58 ms |
14412 KB |
Output is correct |
26 |
Correct |
59 ms |
15552 KB |
Output is correct |
27 |
Correct |
147 ms |
24368 KB |
Output is correct |
28 |
Correct |
148 ms |
28236 KB |
Output is correct |
29 |
Correct |
1 ms |
2644 KB |
Output is correct |
30 |
Correct |
1 ms |
2644 KB |
Output is correct |
31 |
Correct |
1 ms |
2644 KB |
Output is correct |
32 |
Correct |
1 ms |
2644 KB |
Output is correct |
33 |
Incorrect |
1 ms |
2644 KB |
Answer gives possible 0 while actual possible 1 |
34 |
Halted |
0 ms |
0 KB |
- |