# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
864759 | 2023-10-23T14:33:41 Z | andrei_boaca | Connecting Supertrees (IOI20_supertrees) | C++17 | 206 ms | 34108 KB |
#include "supertrees.h" #include <vector> #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; int n; vector<vector<int>> adj; vector<int> muchii[1005],edges[1005]; int comp[1005],nrcomp; bool use[1005]; vector<int> v,nodes; bool good=1; vector<vector<int>> P; void calc(int nod) { use[nod]=1; v.push_back(nod); for(int i:edges[nod]) if(!use[i]) calc(i); } void dfs(int nod) { nodes.push_back(nod); comp[nod]=nrcomp; for(int i:muchii[nod]) if(!comp[i]) dfs(i); } void solve() { for(int i:v) for(int j:v) if(P[i][j]==0) { good=0; return; } vector<int> reprez; for(int i:v) for(int j:v) if(i!=j&&P[i][j]==1) muchii[i].push_back(j); for(int i:v) if(comp[i]==0) { nrcomp++; nodes.clear(); dfs(i); reprez.push_back(nodes[0]); for(int j=1;j<nodes.size();j++) { int a=nodes[j-1]; int b=nodes[j]; adj[a][b]=1; adj[b][a]=1; } } if(reprez.size()==2) { good=0; return; } int lg=reprez.size(); for(int i=0;i<reprez.size();i++) { int a=reprez[i]; int b=reprez[(i+1)%lg]; if(a!=b) adj[a][b]=adj[b][a]=1; } for(int i:v) for(int j:v) if(i!=j) { if(P[i][j]==1&&comp[i]!=comp[j]) { good=0; return; } if(P[i][j]==2&&comp[i]==comp[j]) { good=0; return; } } } int construct(std::vector<std::vector<int>> p) { P=p; good=1; n=p.size(); adj.resize(n); for(int i=0;i<n;i++) adj[i].resize(n); bool sub1=1; bool sub2=1; for(int i=0;i<n;i++) for(int j=0;j<n;j++) { sub1&=(p[i][j]<=2); if(p[i][j]>0&&i!=j) edges[i].push_back(j); } if(sub1) { for(int i=0;i<n;i++) if(!use[i]) { v.clear(); calc(i); solve(); if(good==0) return 0; } build(adj); return 1; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 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 | 7 ms | 1924 KB | Output is correct |
7 | Correct | 162 ms | 34108 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 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 | 7 ms | 1924 KB | Output is correct |
7 | Correct | 162 ms | 34108 KB | Output is correct |
8 | Correct | 1 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 | 348 KB | Output is correct |
12 | Correct | 6 ms | 1468 KB | Output is correct |
13 | Correct | 153 ms | 26168 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 1116 KB | Output is correct |
17 | Correct | 72 ms | 18744 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 38 ms | 6932 KB | Output is correct |
21 | Correct | 152 ms | 27160 KB | Output is correct |
22 | Correct | 153 ms | 26184 KB | Output is correct |
23 | Correct | 160 ms | 30032 KB | Output is correct |
24 | Correct | 149 ms | 26196 KB | Output is correct |
25 | Correct | 62 ms | 16980 KB | Output is correct |
26 | Correct | 64 ms | 16208 KB | Output is correct |
27 | Correct | 161 ms | 32212 KB | Output is correct |
28 | Correct | 151 ms | 26192 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 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 | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 6 ms | 1372 KB | Output is correct |
9 | Correct | 179 ms | 26168 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 7 ms | 1628 KB | Output is correct |
13 | Correct | 157 ms | 30128 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 1112 KB | Output is correct |
17 | Correct | 71 ms | 18748 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 37 ms | 6852 KB | Output is correct |
22 | Correct | 153 ms | 26684 KB | Output is correct |
23 | Correct | 152 ms | 26196 KB | Output is correct |
24 | Correct | 157 ms | 29188 KB | Output is correct |
25 | Correct | 59 ms | 16212 KB | Output is correct |
26 | Correct | 62 ms | 16720 KB | Output is correct |
27 | Correct | 152 ms | 26196 KB | Output is correct |
28 | Correct | 161 ms | 28216 KB | Output is correct |
29 | Correct | 60 ms | 16212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 38 ms | 6888 KB | Output is correct |
5 | Correct | 152 ms | 27216 KB | Output is correct |
6 | Correct | 148 ms | 26196 KB | Output is correct |
7 | Correct | 206 ms | 30036 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 37 ms | 6780 KB | Output is correct |
10 | Correct | 153 ms | 26628 KB | Output is correct |
11 | Correct | 150 ms | 26200 KB | Output is correct |
12 | Correct | 156 ms | 29260 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 37 ms | 7400 KB | Output is correct |
17 | Correct | 151 ms | 28644 KB | Output is correct |
18 | Correct | 152 ms | 28676 KB | Output is correct |
19 | Correct | 151 ms | 28240 KB | Output is correct |
20 | Correct | 152 ms | 28076 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 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 | 7 ms | 1924 KB | Output is correct |
7 | Correct | 162 ms | 34108 KB | Output is correct |
8 | Correct | 1 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 | 348 KB | Output is correct |
12 | Correct | 6 ms | 1468 KB | Output is correct |
13 | Correct | 153 ms | 26168 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 1116 KB | Output is correct |
17 | Correct | 72 ms | 18744 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 38 ms | 6932 KB | Output is correct |
21 | Correct | 152 ms | 27160 KB | Output is correct |
22 | Correct | 153 ms | 26184 KB | Output is correct |
23 | Correct | 160 ms | 30032 KB | Output is correct |
24 | Correct | 149 ms | 26196 KB | Output is correct |
25 | Correct | 62 ms | 16980 KB | Output is correct |
26 | Correct | 64 ms | 16208 KB | Output is correct |
27 | Correct | 161 ms | 32212 KB | Output is correct |
28 | Correct | 151 ms | 26192 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 348 KB | Output is correct |
32 | Correct | 0 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 | 6 ms | 1372 KB | Output is correct |
37 | Correct | 179 ms | 26168 KB | Output is correct |
38 | Correct | 1 ms | 344 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
40 | Correct | 7 ms | 1628 KB | Output is correct |
41 | Correct | 157 ms | 30128 KB | Output is correct |
42 | Correct | 0 ms | 348 KB | Output is correct |
43 | Correct | 0 ms | 348 KB | Output is correct |
44 | Correct | 3 ms | 1112 KB | Output is correct |
45 | Correct | 71 ms | 18748 KB | Output is correct |
46 | Correct | 0 ms | 348 KB | Output is correct |
47 | Correct | 0 ms | 348 KB | Output is correct |
48 | Correct | 0 ms | 348 KB | Output is correct |
49 | Correct | 37 ms | 6852 KB | Output is correct |
50 | Correct | 153 ms | 26684 KB | Output is correct |
51 | Correct | 152 ms | 26196 KB | Output is correct |
52 | Correct | 157 ms | 29188 KB | Output is correct |
53 | Correct | 59 ms | 16212 KB | Output is correct |
54 | Correct | 62 ms | 16720 KB | Output is correct |
55 | Correct | 152 ms | 26196 KB | Output is correct |
56 | Correct | 161 ms | 28216 KB | Output is correct |
57 | Correct | 60 ms | 16212 KB | Output is correct |
58 | Correct | 0 ms | 348 KB | Output is correct |
59 | Correct | 0 ms | 348 KB | Output is correct |
60 | Correct | 3 ms | 1112 KB | Output is correct |
61 | Correct | 71 ms | 20304 KB | Output is correct |
62 | Correct | 0 ms | 348 KB | Output is correct |
63 | Correct | 0 ms | 348 KB | Output is correct |
64 | Correct | 1 ms | 488 KB | Output is correct |
65 | Correct | 37 ms | 7252 KB | Output is correct |
66 | Correct | 66 ms | 18744 KB | Output is correct |
67 | Correct | 64 ms | 18728 KB | Output is correct |
68 | Correct | 64 ms | 18260 KB | Output is correct |
69 | Correct | 61 ms | 18088 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 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 | 7 ms | 1924 KB | Output is correct |
7 | Correct | 162 ms | 34108 KB | Output is correct |
8 | Correct | 1 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 | 348 KB | Output is correct |
12 | Correct | 6 ms | 1468 KB | Output is correct |
13 | Correct | 153 ms | 26168 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 1116 KB | Output is correct |
17 | Correct | 72 ms | 18744 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 38 ms | 6932 KB | Output is correct |
21 | Correct | 152 ms | 27160 KB | Output is correct |
22 | Correct | 153 ms | 26184 KB | Output is correct |
23 | Correct | 160 ms | 30032 KB | Output is correct |
24 | Correct | 149 ms | 26196 KB | Output is correct |
25 | Correct | 62 ms | 16980 KB | Output is correct |
26 | Correct | 64 ms | 16208 KB | Output is correct |
27 | Correct | 161 ms | 32212 KB | Output is correct |
28 | Correct | 151 ms | 26192 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 348 KB | Output is correct |
32 | Correct | 0 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 | 6 ms | 1372 KB | Output is correct |
37 | Correct | 179 ms | 26168 KB | Output is correct |
38 | Correct | 1 ms | 344 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
40 | Correct | 7 ms | 1628 KB | Output is correct |
41 | Correct | 157 ms | 30128 KB | Output is correct |
42 | Correct | 0 ms | 348 KB | Output is correct |
43 | Correct | 0 ms | 348 KB | Output is correct |
44 | Correct | 3 ms | 1112 KB | Output is correct |
45 | Correct | 71 ms | 18748 KB | Output is correct |
46 | Correct | 0 ms | 348 KB | Output is correct |
47 | Correct | 0 ms | 348 KB | Output is correct |
48 | Correct | 0 ms | 348 KB | Output is correct |
49 | Correct | 37 ms | 6852 KB | Output is correct |
50 | Correct | 153 ms | 26684 KB | Output is correct |
51 | Correct | 152 ms | 26196 KB | Output is correct |
52 | Correct | 157 ms | 29188 KB | Output is correct |
53 | Correct | 59 ms | 16212 KB | Output is correct |
54 | Correct | 62 ms | 16720 KB | Output is correct |
55 | Correct | 152 ms | 26196 KB | Output is correct |
56 | Correct | 161 ms | 28216 KB | Output is correct |
57 | Correct | 60 ms | 16212 KB | Output is correct |
58 | Correct | 0 ms | 348 KB | Output is correct |
59 | Correct | 0 ms | 348 KB | Output is correct |
60 | Correct | 0 ms | 348 KB | Output is correct |
61 | Correct | 38 ms | 6888 KB | Output is correct |
62 | Correct | 152 ms | 27216 KB | Output is correct |
63 | Correct | 148 ms | 26196 KB | Output is correct |
64 | Correct | 206 ms | 30036 KB | Output is correct |
65 | Correct | 0 ms | 348 KB | Output is correct |
66 | Correct | 37 ms | 6780 KB | Output is correct |
67 | Correct | 153 ms | 26628 KB | Output is correct |
68 | Correct | 150 ms | 26200 KB | Output is correct |
69 | Correct | 156 ms | 29260 KB | Output is correct |
70 | Correct | 0 ms | 348 KB | Output is correct |
71 | Correct | 0 ms | 348 KB | Output is correct |
72 | Correct | 0 ms | 348 KB | Output is correct |
73 | Correct | 37 ms | 7400 KB | Output is correct |
74 | Correct | 151 ms | 28644 KB | Output is correct |
75 | Correct | 152 ms | 28676 KB | Output is correct |
76 | Correct | 151 ms | 28240 KB | Output is correct |
77 | Correct | 152 ms | 28076 KB | Output is correct |
78 | Correct | 0 ms | 348 KB | Output is correct |
79 | Correct | 0 ms | 348 KB | Output is correct |
80 | Correct | 3 ms | 1112 KB | Output is correct |
81 | Correct | 71 ms | 20304 KB | Output is correct |
82 | Correct | 0 ms | 348 KB | Output is correct |
83 | Correct | 0 ms | 348 KB | Output is correct |
84 | Correct | 1 ms | 488 KB | Output is correct |
85 | Correct | 37 ms | 7252 KB | Output is correct |
86 | Correct | 66 ms | 18744 KB | Output is correct |
87 | Correct | 64 ms | 18728 KB | Output is correct |
88 | Correct | 64 ms | 18260 KB | Output is correct |
89 | Correct | 61 ms | 18088 KB | Output is correct |
90 | Correct | 0 ms | 348 KB | Output is correct |
91 | Correct | 0 ms | 348 KB | Output is correct |
92 | Correct | 3 ms | 1372 KB | Output is correct |
93 | Correct | 73 ms | 22100 KB | Output is correct |
94 | Correct | 0 ms | 344 KB | Output is correct |
95 | Correct | 0 ms | 348 KB | Output is correct |
96 | Correct | 0 ms | 348 KB | Output is correct |
97 | Correct | 16 ms | 4956 KB | Output is correct |
98 | Correct | 62 ms | 18652 KB | Output is correct |
99 | Correct | 62 ms | 18728 KB | Output is correct |
100 | Correct | 71 ms | 18356 KB | Output is correct |
101 | Correct | 61 ms | 18168 KB | Output is correct |
102 | Correct | 67 ms | 22100 KB | Output is correct |
103 | Correct | 66 ms | 22100 KB | Output is correct |
104 | Correct | 65 ms | 22100 KB | Output is correct |
105 | Correct | 72 ms | 20520 KB | Output is correct |