#include <bits/stdc++.h>
#include "supertrees.h"
using namespace std;
#define N 100005
#define wr cout << "Continue debugging\n";
#define all(x) (x).begin(), (x).end()
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second
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]){
ok[j] = 1;
v.pb(j);
}
}
if (!v.size()) continue;
v.push_front(i);
for (int j = 0; j < v.size(); j++){
for (int k = j+1; k < v.size(); k++) if (p[v[j]][v[k]] != 2) return 0;
}
b[v[0]][v.back()] = b[v.back()][v[0]] = 1;
for (int j = 1; j < 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);
// }
Compilation message
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:47:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for (int j = 0; j < v.size(); j++){
| ~~^~~~~~~~~~
supertrees.cpp:48:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
48 | for (int k = j+1; k < v.size(); k++) if (p[v[j]][v[k]] != 2) return 0;
| ~~^~~~~~~~~~
supertrees.cpp:51:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
51 | for (int j = 1; j < v.size(); j++){
| ~~^~~~~~~~~~
# |
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 |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
1 ms |
2644 KB |
Output is correct |
6 |
Correct |
8 ms |
3540 KB |
Output is correct |
7 |
Correct |
163 ms |
24324 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 |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
1 ms |
2644 KB |
Output is correct |
6 |
Correct |
8 ms |
3540 KB |
Output is correct |
7 |
Correct |
163 ms |
24324 KB |
Output is correct |
8 |
Correct |
1 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2644 KB |
Output is correct |
10 |
Correct |
1 ms |
2644 KB |
Output is correct |
11 |
Correct |
2 ms |
2644 KB |
Output is correct |
12 |
Correct |
8 ms |
3668 KB |
Output is correct |
13 |
Correct |
175 ms |
28308 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 |
78 ms |
14396 KB |
Output is correct |
18 |
Correct |
1 ms |
2644 KB |
Output is correct |
19 |
Correct |
1 ms |
2644 KB |
Output is correct |
20 |
Correct |
42 ms |
8244 KB |
Output is correct |
21 |
Correct |
167 ms |
24396 KB |
Output is correct |
22 |
Correct |
186 ms |
25904 KB |
Output is correct |
23 |
Correct |
168 ms |
24388 KB |
Output is correct |
24 |
Correct |
174 ms |
28208 KB |
Output is correct |
25 |
Correct |
77 ms |
14516 KB |
Output is correct |
26 |
Correct |
85 ms |
15552 KB |
Output is correct |
27 |
Correct |
185 ms |
24356 KB |
Output is correct |
28 |
Correct |
176 ms |
28216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2576 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Incorrect |
1 ms |
2644 KB |
Answer gives possible 1 while actual possible 0 |
5 |
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 |
47 ms |
8368 KB |
Output is correct |
5 |
Correct |
166 ms |
24368 KB |
Output is correct |
6 |
Correct |
167 ms |
25932 KB |
Output is correct |
7 |
Correct |
169 ms |
24376 KB |
Output is correct |
8 |
Correct |
1 ms |
2644 KB |
Output is correct |
9 |
Correct |
43 ms |
9036 KB |
Output is correct |
10 |
Correct |
170 ms |
28336 KB |
Output is correct |
11 |
Correct |
174 ms |
28340 KB |
Output is correct |
12 |
Correct |
171 ms |
28416 KB |
Output is correct |
13 |
Correct |
1 ms |
2644 KB |
Output is correct |
14 |
Correct |
1 ms |
2644 KB |
Output is correct |
15 |
Correct |
1 ms |
2644 KB |
Output is correct |
16 |
Correct |
52 ms |
8908 KB |
Output is correct |
17 |
Correct |
170 ms |
28340 KB |
Output is correct |
18 |
Correct |
171 ms |
26688 KB |
Output is correct |
19 |
Correct |
168 ms |
26816 KB |
Output is correct |
20 |
Correct |
188 ms |
28292 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 |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
1 ms |
2644 KB |
Output is correct |
6 |
Correct |
8 ms |
3540 KB |
Output is correct |
7 |
Correct |
163 ms |
24324 KB |
Output is correct |
8 |
Correct |
1 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2644 KB |
Output is correct |
10 |
Correct |
1 ms |
2644 KB |
Output is correct |
11 |
Correct |
2 ms |
2644 KB |
Output is correct |
12 |
Correct |
8 ms |
3668 KB |
Output is correct |
13 |
Correct |
175 ms |
28308 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 |
78 ms |
14396 KB |
Output is correct |
18 |
Correct |
1 ms |
2644 KB |
Output is correct |
19 |
Correct |
1 ms |
2644 KB |
Output is correct |
20 |
Correct |
42 ms |
8244 KB |
Output is correct |
21 |
Correct |
167 ms |
24396 KB |
Output is correct |
22 |
Correct |
186 ms |
25904 KB |
Output is correct |
23 |
Correct |
168 ms |
24388 KB |
Output is correct |
24 |
Correct |
174 ms |
28208 KB |
Output is correct |
25 |
Correct |
77 ms |
14516 KB |
Output is correct |
26 |
Correct |
85 ms |
15552 KB |
Output is correct |
27 |
Correct |
185 ms |
24356 KB |
Output is correct |
28 |
Correct |
176 ms |
28216 KB |
Output is correct |
29 |
Correct |
2 ms |
2576 KB |
Output is correct |
30 |
Correct |
1 ms |
2644 KB |
Output is correct |
31 |
Correct |
1 ms |
2644 KB |
Output is correct |
32 |
Incorrect |
1 ms |
2644 KB |
Answer gives possible 1 while actual possible 0 |
33 |
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 |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
1 ms |
2644 KB |
Output is correct |
6 |
Correct |
8 ms |
3540 KB |
Output is correct |
7 |
Correct |
163 ms |
24324 KB |
Output is correct |
8 |
Correct |
1 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2644 KB |
Output is correct |
10 |
Correct |
1 ms |
2644 KB |
Output is correct |
11 |
Correct |
2 ms |
2644 KB |
Output is correct |
12 |
Correct |
8 ms |
3668 KB |
Output is correct |
13 |
Correct |
175 ms |
28308 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 |
78 ms |
14396 KB |
Output is correct |
18 |
Correct |
1 ms |
2644 KB |
Output is correct |
19 |
Correct |
1 ms |
2644 KB |
Output is correct |
20 |
Correct |
42 ms |
8244 KB |
Output is correct |
21 |
Correct |
167 ms |
24396 KB |
Output is correct |
22 |
Correct |
186 ms |
25904 KB |
Output is correct |
23 |
Correct |
168 ms |
24388 KB |
Output is correct |
24 |
Correct |
174 ms |
28208 KB |
Output is correct |
25 |
Correct |
77 ms |
14516 KB |
Output is correct |
26 |
Correct |
85 ms |
15552 KB |
Output is correct |
27 |
Correct |
185 ms |
24356 KB |
Output is correct |
28 |
Correct |
176 ms |
28216 KB |
Output is correct |
29 |
Correct |
2 ms |
2576 KB |
Output is correct |
30 |
Correct |
1 ms |
2644 KB |
Output is correct |
31 |
Correct |
1 ms |
2644 KB |
Output is correct |
32 |
Incorrect |
1 ms |
2644 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |