///~~~LOTA~~~///
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define N 1000
int cc[N];
int cn[N];
int vis[N];
int construct(vector<vector<int>> a){
int n,m;
n=a.size();
vector<int> u;
vector<vector<int>> v,x,ans;
for(int i=0;i<n;i++){
if(!vis[i]){
for(int j=i;j<n;j++){
if(a[i][j]==1){
u.append(j);
vis[j]=1;
}
}
v.append(u);
u.clear();
}
vis[i]=0;
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)
u.append(0);
ans.append(u);
u.clear();
}
for(auto& k:v){
for(int i=0;i<k.size();i++){
for(int j=i;j<k.size();j++){
if(a[k[i]][k[j]]!=1)
return 0;
}
}
}
for(int i=0;i<v.size();i++){
if(!vis[i]){
for(auto& j:v[i]){
cn[j]=u.size();
cc[j]=i;
}
u.append(i);
for(int j=i+1;j<v.size();j++){
if(a[v[i][0]][v[j][0]]==2){
for(auto& k:v[j]){
cn[k]=u.size();
cc[k]=i;
}
u.append(j);
vis[j]=1;
}
}
x.append(u);
if(u.size()==2)
return 0;
if(u.size()==1)
x.pop_back();
u.clear();
}
vis[i]=0;
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(cc[i]!=cc[j] && a[i][j]!=0)
return 0;
if(cc[i]==cc[j] && cn[i]==cn[j] && a[i][j]!=1)
return 0;
if(cc[i]==cc[j] && cn[i]!=cn[j] && a[i][j]!=2)
return 0;
}
}
for(auto& i:v){
for(int j=1;j<i.size();j++)
ans[i[j]][i[j-1]]=ans[i[j-1]][i[j]]=1;}
for(auto& i:x){
m=i.size()-1;
for(int j=0;j<m;j++)
ans[v[i[j]][0]][v[i[j+1]][0]]=ans[v[i[j+1]][0]][v[i[j]][0]]=1;
ans[v[i[0]][0]][v[i[m]][0]]=ans[v[i[m]][0]][v[i[0]][0]]=1;
}
build(ans);
return 1;
}
Compilation message
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(int i=0;i<k.size();i++){
| ~^~~~~~~~~
supertrees.cpp:47:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for(int j=i;j<k.size();j++){
| ~^~~~~~~~~
supertrees.cpp:53:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for(int i=0;i<v.size();i++){
| ~^~~~~~~~~
supertrees.cpp:60:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | for(int j=i+1;j<v.size();j++){
| ~^~~~~~~~~
supertrees.cpp:90:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
90 | for(int j=1;j<i.size();j++)
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
1272 KB |
Output is correct |
7 |
Correct |
118 ms |
23888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
1272 KB |
Output is correct |
7 |
Correct |
118 ms |
23888 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
440 KB |
Output is correct |
12 |
Correct |
6 ms |
1372 KB |
Output is correct |
13 |
Correct |
121 ms |
23988 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
932 KB |
Output is correct |
17 |
Correct |
64 ms |
14216 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
30 ms |
6268 KB |
Output is correct |
21 |
Correct |
123 ms |
24144 KB |
Output is correct |
22 |
Correct |
126 ms |
24144 KB |
Output is correct |
23 |
Correct |
125 ms |
24148 KB |
Output is correct |
24 |
Correct |
114 ms |
24144 KB |
Output is correct |
25 |
Correct |
58 ms |
14164 KB |
Output is correct |
26 |
Correct |
51 ms |
14160 KB |
Output is correct |
27 |
Correct |
124 ms |
24036 KB |
Output is correct |
28 |
Correct |
118 ms |
24064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
5 ms |
1372 KB |
Output is correct |
9 |
Correct |
117 ms |
24148 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
7 ms |
1224 KB |
Output is correct |
13 |
Correct |
130 ms |
24148 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
860 KB |
Output is correct |
17 |
Correct |
62 ms |
14164 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
31 ms |
6400 KB |
Output is correct |
22 |
Correct |
122 ms |
24148 KB |
Output is correct |
23 |
Correct |
119 ms |
24200 KB |
Output is correct |
24 |
Correct |
127 ms |
24060 KB |
Output is correct |
25 |
Correct |
52 ms |
14252 KB |
Output is correct |
26 |
Correct |
53 ms |
14160 KB |
Output is correct |
27 |
Correct |
117 ms |
24204 KB |
Output is correct |
28 |
Correct |
125 ms |
24188 KB |
Output is correct |
29 |
Correct |
57 ms |
14164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
30 ms |
6228 KB |
Output is correct |
5 |
Correct |
124 ms |
24148 KB |
Output is correct |
6 |
Correct |
131 ms |
24148 KB |
Output is correct |
7 |
Correct |
126 ms |
24064 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
31 ms |
6256 KB |
Output is correct |
10 |
Correct |
132 ms |
24152 KB |
Output is correct |
11 |
Correct |
119 ms |
24072 KB |
Output is correct |
12 |
Correct |
126 ms |
24184 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
30 ms |
6404 KB |
Output is correct |
17 |
Correct |
124 ms |
24144 KB |
Output is correct |
18 |
Correct |
128 ms |
24400 KB |
Output is correct |
19 |
Correct |
122 ms |
24072 KB |
Output is correct |
20 |
Correct |
120 ms |
24148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
1272 KB |
Output is correct |
7 |
Correct |
118 ms |
23888 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
440 KB |
Output is correct |
12 |
Correct |
6 ms |
1372 KB |
Output is correct |
13 |
Correct |
121 ms |
23988 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
932 KB |
Output is correct |
17 |
Correct |
64 ms |
14216 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
30 ms |
6268 KB |
Output is correct |
21 |
Correct |
123 ms |
24144 KB |
Output is correct |
22 |
Correct |
126 ms |
24144 KB |
Output is correct |
23 |
Correct |
125 ms |
24148 KB |
Output is correct |
24 |
Correct |
114 ms |
24144 KB |
Output is correct |
25 |
Correct |
58 ms |
14164 KB |
Output is correct |
26 |
Correct |
51 ms |
14160 KB |
Output is correct |
27 |
Correct |
124 ms |
24036 KB |
Output is correct |
28 |
Correct |
118 ms |
24064 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
5 ms |
1372 KB |
Output is correct |
37 |
Correct |
117 ms |
24148 KB |
Output is correct |
38 |
Correct |
1 ms |
348 KB |
Output is correct |
39 |
Correct |
0 ms |
348 KB |
Output is correct |
40 |
Correct |
7 ms |
1224 KB |
Output is correct |
41 |
Correct |
130 ms |
24148 KB |
Output is correct |
42 |
Correct |
0 ms |
344 KB |
Output is correct |
43 |
Correct |
0 ms |
348 KB |
Output is correct |
44 |
Correct |
3 ms |
860 KB |
Output is correct |
45 |
Correct |
62 ms |
14164 KB |
Output is correct |
46 |
Correct |
0 ms |
348 KB |
Output is correct |
47 |
Correct |
1 ms |
348 KB |
Output is correct |
48 |
Correct |
1 ms |
348 KB |
Output is correct |
49 |
Correct |
31 ms |
6400 KB |
Output is correct |
50 |
Correct |
122 ms |
24148 KB |
Output is correct |
51 |
Correct |
119 ms |
24200 KB |
Output is correct |
52 |
Correct |
127 ms |
24060 KB |
Output is correct |
53 |
Correct |
52 ms |
14252 KB |
Output is correct |
54 |
Correct |
53 ms |
14160 KB |
Output is correct |
55 |
Correct |
117 ms |
24204 KB |
Output is correct |
56 |
Correct |
125 ms |
24188 KB |
Output is correct |
57 |
Correct |
57 ms |
14164 KB |
Output is correct |
58 |
Correct |
0 ms |
344 KB |
Output is correct |
59 |
Correct |
1 ms |
348 KB |
Output is correct |
60 |
Correct |
3 ms |
860 KB |
Output is correct |
61 |
Correct |
59 ms |
14216 KB |
Output is correct |
62 |
Correct |
0 ms |
348 KB |
Output is correct |
63 |
Correct |
0 ms |
360 KB |
Output is correct |
64 |
Correct |
0 ms |
344 KB |
Output is correct |
65 |
Correct |
31 ms |
6236 KB |
Output is correct |
66 |
Correct |
61 ms |
14220 KB |
Output is correct |
67 |
Correct |
54 ms |
14092 KB |
Output is correct |
68 |
Correct |
56 ms |
14088 KB |
Output is correct |
69 |
Correct |
54 ms |
14220 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
1272 KB |
Output is correct |
7 |
Correct |
118 ms |
23888 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
440 KB |
Output is correct |
12 |
Correct |
6 ms |
1372 KB |
Output is correct |
13 |
Correct |
121 ms |
23988 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
932 KB |
Output is correct |
17 |
Correct |
64 ms |
14216 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
30 ms |
6268 KB |
Output is correct |
21 |
Correct |
123 ms |
24144 KB |
Output is correct |
22 |
Correct |
126 ms |
24144 KB |
Output is correct |
23 |
Correct |
125 ms |
24148 KB |
Output is correct |
24 |
Correct |
114 ms |
24144 KB |
Output is correct |
25 |
Correct |
58 ms |
14164 KB |
Output is correct |
26 |
Correct |
51 ms |
14160 KB |
Output is correct |
27 |
Correct |
124 ms |
24036 KB |
Output is correct |
28 |
Correct |
118 ms |
24064 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
5 ms |
1372 KB |
Output is correct |
37 |
Correct |
117 ms |
24148 KB |
Output is correct |
38 |
Correct |
1 ms |
348 KB |
Output is correct |
39 |
Correct |
0 ms |
348 KB |
Output is correct |
40 |
Correct |
7 ms |
1224 KB |
Output is correct |
41 |
Correct |
130 ms |
24148 KB |
Output is correct |
42 |
Correct |
0 ms |
344 KB |
Output is correct |
43 |
Correct |
0 ms |
348 KB |
Output is correct |
44 |
Correct |
3 ms |
860 KB |
Output is correct |
45 |
Correct |
62 ms |
14164 KB |
Output is correct |
46 |
Correct |
0 ms |
348 KB |
Output is correct |
47 |
Correct |
1 ms |
348 KB |
Output is correct |
48 |
Correct |
1 ms |
348 KB |
Output is correct |
49 |
Correct |
31 ms |
6400 KB |
Output is correct |
50 |
Correct |
122 ms |
24148 KB |
Output is correct |
51 |
Correct |
119 ms |
24200 KB |
Output is correct |
52 |
Correct |
127 ms |
24060 KB |
Output is correct |
53 |
Correct |
52 ms |
14252 KB |
Output is correct |
54 |
Correct |
53 ms |
14160 KB |
Output is correct |
55 |
Correct |
117 ms |
24204 KB |
Output is correct |
56 |
Correct |
125 ms |
24188 KB |
Output is correct |
57 |
Correct |
57 ms |
14164 KB |
Output is correct |
58 |
Correct |
1 ms |
348 KB |
Output is correct |
59 |
Correct |
0 ms |
348 KB |
Output is correct |
60 |
Correct |
0 ms |
344 KB |
Output is correct |
61 |
Correct |
30 ms |
6228 KB |
Output is correct |
62 |
Correct |
124 ms |
24148 KB |
Output is correct |
63 |
Correct |
131 ms |
24148 KB |
Output is correct |
64 |
Correct |
126 ms |
24064 KB |
Output is correct |
65 |
Correct |
0 ms |
348 KB |
Output is correct |
66 |
Correct |
31 ms |
6256 KB |
Output is correct |
67 |
Correct |
132 ms |
24152 KB |
Output is correct |
68 |
Correct |
119 ms |
24072 KB |
Output is correct |
69 |
Correct |
126 ms |
24184 KB |
Output is correct |
70 |
Correct |
1 ms |
344 KB |
Output is correct |
71 |
Correct |
1 ms |
348 KB |
Output is correct |
72 |
Correct |
1 ms |
348 KB |
Output is correct |
73 |
Correct |
30 ms |
6404 KB |
Output is correct |
74 |
Correct |
124 ms |
24144 KB |
Output is correct |
75 |
Correct |
128 ms |
24400 KB |
Output is correct |
76 |
Correct |
122 ms |
24072 KB |
Output is correct |
77 |
Correct |
120 ms |
24148 KB |
Output is correct |
78 |
Correct |
0 ms |
344 KB |
Output is correct |
79 |
Correct |
1 ms |
348 KB |
Output is correct |
80 |
Correct |
3 ms |
860 KB |
Output is correct |
81 |
Correct |
59 ms |
14216 KB |
Output is correct |
82 |
Correct |
0 ms |
348 KB |
Output is correct |
83 |
Correct |
0 ms |
360 KB |
Output is correct |
84 |
Correct |
0 ms |
344 KB |
Output is correct |
85 |
Correct |
31 ms |
6236 KB |
Output is correct |
86 |
Correct |
61 ms |
14220 KB |
Output is correct |
87 |
Correct |
54 ms |
14092 KB |
Output is correct |
88 |
Correct |
56 ms |
14088 KB |
Output is correct |
89 |
Correct |
54 ms |
14220 KB |
Output is correct |
90 |
Correct |
1 ms |
344 KB |
Output is correct |
91 |
Correct |
0 ms |
348 KB |
Output is correct |
92 |
Correct |
2 ms |
860 KB |
Output is correct |
93 |
Correct |
56 ms |
14220 KB |
Output is correct |
94 |
Correct |
1 ms |
348 KB |
Output is correct |
95 |
Correct |
0 ms |
348 KB |
Output is correct |
96 |
Correct |
1 ms |
348 KB |
Output is correct |
97 |
Correct |
16 ms |
3932 KB |
Output is correct |
98 |
Correct |
56 ms |
14164 KB |
Output is correct |
99 |
Correct |
62 ms |
14160 KB |
Output is correct |
100 |
Correct |
54 ms |
14164 KB |
Output is correct |
101 |
Correct |
54 ms |
14164 KB |
Output is correct |
102 |
Correct |
55 ms |
14160 KB |
Output is correct |
103 |
Correct |
56 ms |
14164 KB |
Output is correct |
104 |
Correct |
54 ms |
14164 KB |
Output is correct |
105 |
Correct |
63 ms |
14204 KB |
Output is correct |