# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
366902 | 2021-02-15T16:37:55 Z | rumen_m | Connecting Supertrees (IOI20_supertrees) | C++17 | 298 ms | 34924 KB |
#include "supertrees.h" #include <vector> #include <bits/stdc++.h> using namespace std; const int maxn = 3005; vector <short> g[maxn]; vector <short> ones[maxn]; short id[maxn], ids = 0; bool vis[maxn]; vector <int> groups[maxn]; short ans[maxn][maxn]; short newids[maxn]; void dfs(int v) { id[v]=ids; int i; for(i=0;i<g[v].size();i++) { if(id[g[v][i]]==0)dfs(g[v][i]); } } void solve(int v) { newids[v] = ids; vis[v] = 1; int i; for(i=0;i<ones[v].size();i++) { if(!vis[ones[v][i]]) { ans[v][ones[v][i]] = 1; solve(ones[v][i]); } } } int construct(std::vector<std::vector<int>> p) { int n = p.size(); int i,j,t; for(i=0;i<n;i++) for(j=0;j<n;j++) { if(i==j)continue; if(p[i][j]==3)return 0; if(p[i][j]>0) { /* for(t=0;t<n;t++) { if((p[i][t]>0)^(p[j][t]>0)==1)return 0; if(p[i][j]==1) if(p[i][t]==1^p[j][t]==1)return 0; }*/ } if(p[i][j]!=0) { g[i].push_back(j); g[j].push_back(i); } if(p[i][j]==1) { ones[i].push_back(j); ones[j].push_back(i); } } for(i=0;i<n;i++) { if(id[i]==0){ids++;dfs(i);} } for(i=0;i<n;i++) { if(!vis[i]) { groups[id[i]].push_back(i); ids++; solve(i); } } for(i=1;i<=ids;i++) { if(groups[i].size()==2)return 0; if(groups[i].size()<=2)continue; ans[groups[i][0]][groups[i][groups[i].size()-1]] = 1; for(j=1;j<groups[i].size();j++) { ans[groups[i][j-1]][groups[i][j]] = 1; } } std::vector<std::vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row; row.resize(n); for(j=0;j<n;j++) { row[j] = ans[i][j]|ans[j][i]; if(i==j)continue; if(p[i][j]==0&&id[i]==id[j]){return 0;} if(p[i][j]==1&&newids[i]!=newids[j])return 0; } answer.push_back(row); } build(answer); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 492 KB | Output is correct |
4 | Correct | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 620 KB | Output is correct |
6 | Correct | 13 ms | 2668 KB | Output is correct |
7 | Correct | 287 ms | 34540 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 492 KB | Output is correct |
4 | Correct | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 620 KB | Output is correct |
6 | Correct | 13 ms | 2668 KB | Output is correct |
7 | Correct | 287 ms | 34540 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 512 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 13 ms | 1388 KB | Output is correct |
13 | Correct | 245 ms | 22380 KB | Output is correct |
14 | Correct | 1 ms | 492 KB | Output is correct |
15 | Correct | 1 ms | 620 KB | Output is correct |
16 | Correct | 9 ms | 2028 KB | Output is correct |
17 | Correct | 137 ms | 19692 KB | Output is correct |
18 | Correct | 1 ms | 640 KB | Output is correct |
19 | Correct | 1 ms | 492 KB | Output is correct |
20 | Correct | 63 ms | 8428 KB | Output is correct |
21 | Correct | 255 ms | 29420 KB | Output is correct |
22 | Correct | 244 ms | 26752 KB | Output is correct |
23 | Correct | 279 ms | 32492 KB | Output is correct |
24 | Correct | 247 ms | 24684 KB | Output is correct |
25 | Correct | 109 ms | 15468 KB | Output is correct |
26 | Correct | 104 ms | 13036 KB | Output is correct |
27 | Correct | 281 ms | 34924 KB | Output is correct |
28 | Correct | 244 ms | 24684 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 492 KB | Output is correct |
4 | Correct | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 492 KB | Output is correct |
6 | Correct | 1 ms | 492 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 11 ms | 1388 KB | Output is correct |
9 | Correct | 298 ms | 22380 KB | Output is correct |
10 | Correct | 1 ms | 640 KB | Output is correct |
11 | Correct | 1 ms | 620 KB | Output is correct |
12 | Correct | 12 ms | 2540 KB | Output is correct |
13 | Correct | 261 ms | 30828 KB | Output is correct |
14 | Correct | 1 ms | 620 KB | Output is correct |
15 | Correct | 1 ms | 620 KB | Output is correct |
16 | Correct | 6 ms | 1900 KB | Output is correct |
17 | Correct | 122 ms | 17260 KB | Output is correct |
18 | Correct | 1 ms | 492 KB | Output is correct |
19 | Correct | 1 ms | 492 KB | Output is correct |
20 | Correct | 1 ms | 492 KB | Output is correct |
21 | Correct | 63 ms | 8300 KB | Output is correct |
22 | Correct | 263 ms | 28908 KB | Output is correct |
23 | Correct | 242 ms | 27756 KB | Output is correct |
24 | Correct | 273 ms | 31852 KB | Output is correct |
25 | Correct | 105 ms | 10604 KB | Output is correct |
26 | Correct | 107 ms | 14956 KB | Output is correct |
27 | Correct | 249 ms | 28012 KB | Output is correct |
28 | Correct | 274 ms | 30316 KB | Output is correct |
29 | Correct | 102 ms | 10604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 492 KB | Output is correct |
4 | Correct | 63 ms | 7916 KB | Output is correct |
5 | Correct | 254 ms | 27372 KB | Output is correct |
6 | Correct | 268 ms | 24940 KB | Output is correct |
7 | Correct | 280 ms | 30444 KB | Output is correct |
8 | Correct | 1 ms | 620 KB | Output is correct |
9 | Correct | 63 ms | 7916 KB | Output is correct |
10 | Correct | 256 ms | 26860 KB | Output is correct |
11 | Correct | 247 ms | 27884 KB | Output is correct |
12 | Correct | 265 ms | 31724 KB | Output is correct |
13 | Correct | 1 ms | 492 KB | Output is correct |
14 | Correct | 1 ms | 620 KB | Output is correct |
15 | Correct | 1 ms | 620 KB | Output is correct |
16 | Correct | 62 ms | 8172 KB | Output is correct |
17 | Correct | 251 ms | 28772 KB | Output is correct |
18 | Correct | 254 ms | 28396 KB | Output is correct |
19 | Correct | 260 ms | 28268 KB | Output is correct |
20 | Correct | 244 ms | 24428 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 492 KB | Output is correct |
4 | Correct | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 620 KB | Output is correct |
6 | Correct | 13 ms | 2668 KB | Output is correct |
7 | Correct | 287 ms | 34540 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 512 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 13 ms | 1388 KB | Output is correct |
13 | Correct | 245 ms | 22380 KB | Output is correct |
14 | Correct | 1 ms | 492 KB | Output is correct |
15 | Correct | 1 ms | 620 KB | Output is correct |
16 | Correct | 9 ms | 2028 KB | Output is correct |
17 | Correct | 137 ms | 19692 KB | Output is correct |
18 | Correct | 1 ms | 640 KB | Output is correct |
19 | Correct | 1 ms | 492 KB | Output is correct |
20 | Correct | 63 ms | 8428 KB | Output is correct |
21 | Correct | 255 ms | 29420 KB | Output is correct |
22 | Correct | 244 ms | 26752 KB | Output is correct |
23 | Correct | 279 ms | 32492 KB | Output is correct |
24 | Correct | 247 ms | 24684 KB | Output is correct |
25 | Correct | 109 ms | 15468 KB | Output is correct |
26 | Correct | 104 ms | 13036 KB | Output is correct |
27 | Correct | 281 ms | 34924 KB | Output is correct |
28 | Correct | 244 ms | 24684 KB | Output is correct |
29 | Correct | 1 ms | 492 KB | Output is correct |
30 | Correct | 1 ms | 492 KB | Output is correct |
31 | Correct | 1 ms | 492 KB | Output is correct |
32 | Correct | 1 ms | 492 KB | Output is correct |
33 | Correct | 1 ms | 492 KB | Output is correct |
34 | Correct | 1 ms | 492 KB | Output is correct |
35 | Correct | 1 ms | 492 KB | Output is correct |
36 | Correct | 11 ms | 1388 KB | Output is correct |
37 | Correct | 298 ms | 22380 KB | Output is correct |
38 | Correct | 1 ms | 640 KB | Output is correct |
39 | Correct | 1 ms | 620 KB | Output is correct |
40 | Correct | 12 ms | 2540 KB | Output is correct |
41 | Correct | 261 ms | 30828 KB | Output is correct |
42 | Correct | 1 ms | 620 KB | Output is correct |
43 | Correct | 1 ms | 620 KB | Output is correct |
44 | Correct | 6 ms | 1900 KB | Output is correct |
45 | Correct | 122 ms | 17260 KB | Output is correct |
46 | Correct | 1 ms | 492 KB | Output is correct |
47 | Correct | 1 ms | 492 KB | Output is correct |
48 | Correct | 1 ms | 492 KB | Output is correct |
49 | Correct | 63 ms | 8300 KB | Output is correct |
50 | Correct | 263 ms | 28908 KB | Output is correct |
51 | Correct | 242 ms | 27756 KB | Output is correct |
52 | Correct | 273 ms | 31852 KB | Output is correct |
53 | Correct | 105 ms | 10604 KB | Output is correct |
54 | Correct | 107 ms | 14956 KB | Output is correct |
55 | Correct | 249 ms | 28012 KB | Output is correct |
56 | Correct | 274 ms | 30316 KB | Output is correct |
57 | Correct | 102 ms | 10604 KB | Output is correct |
58 | Correct | 1 ms | 492 KB | Output is correct |
59 | Correct | 1 ms | 620 KB | Output is correct |
60 | Correct | 6 ms | 2028 KB | Output is correct |
61 | Correct | 140 ms | 21100 KB | Output is correct |
62 | Correct | 1 ms | 620 KB | Output is correct |
63 | Correct | 1 ms | 620 KB | Output is correct |
64 | Correct | 1 ms | 620 KB | Output is correct |
65 | Correct | 66 ms | 8172 KB | Output is correct |
66 | Correct | 105 ms | 15084 KB | Output is correct |
67 | Correct | 108 ms | 14444 KB | Output is correct |
68 | Correct | 102 ms | 14444 KB | Output is correct |
69 | Correct | 101 ms | 10752 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 492 KB | Output is correct |
4 | Correct | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 620 KB | Output is correct |
6 | Correct | 13 ms | 2668 KB | Output is correct |
7 | Correct | 287 ms | 34540 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 512 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 13 ms | 1388 KB | Output is correct |
13 | Correct | 245 ms | 22380 KB | Output is correct |
14 | Correct | 1 ms | 492 KB | Output is correct |
15 | Correct | 1 ms | 620 KB | Output is correct |
16 | Correct | 9 ms | 2028 KB | Output is correct |
17 | Correct | 137 ms | 19692 KB | Output is correct |
18 | Correct | 1 ms | 640 KB | Output is correct |
19 | Correct | 1 ms | 492 KB | Output is correct |
20 | Correct | 63 ms | 8428 KB | Output is correct |
21 | Correct | 255 ms | 29420 KB | Output is correct |
22 | Correct | 244 ms | 26752 KB | Output is correct |
23 | Correct | 279 ms | 32492 KB | Output is correct |
24 | Correct | 247 ms | 24684 KB | Output is correct |
25 | Correct | 109 ms | 15468 KB | Output is correct |
26 | Correct | 104 ms | 13036 KB | Output is correct |
27 | Correct | 281 ms | 34924 KB | Output is correct |
28 | Correct | 244 ms | 24684 KB | Output is correct |
29 | Correct | 1 ms | 492 KB | Output is correct |
30 | Correct | 1 ms | 492 KB | Output is correct |
31 | Correct | 1 ms | 492 KB | Output is correct |
32 | Correct | 1 ms | 492 KB | Output is correct |
33 | Correct | 1 ms | 492 KB | Output is correct |
34 | Correct | 1 ms | 492 KB | Output is correct |
35 | Correct | 1 ms | 492 KB | Output is correct |
36 | Correct | 11 ms | 1388 KB | Output is correct |
37 | Correct | 298 ms | 22380 KB | Output is correct |
38 | Correct | 1 ms | 640 KB | Output is correct |
39 | Correct | 1 ms | 620 KB | Output is correct |
40 | Correct | 12 ms | 2540 KB | Output is correct |
41 | Correct | 261 ms | 30828 KB | Output is correct |
42 | Correct | 1 ms | 620 KB | Output is correct |
43 | Correct | 1 ms | 620 KB | Output is correct |
44 | Correct | 6 ms | 1900 KB | Output is correct |
45 | Correct | 122 ms | 17260 KB | Output is correct |
46 | Correct | 1 ms | 492 KB | Output is correct |
47 | Correct | 1 ms | 492 KB | Output is correct |
48 | Correct | 1 ms | 492 KB | Output is correct |
49 | Correct | 63 ms | 8300 KB | Output is correct |
50 | Correct | 263 ms | 28908 KB | Output is correct |
51 | Correct | 242 ms | 27756 KB | Output is correct |
52 | Correct | 273 ms | 31852 KB | Output is correct |
53 | Correct | 105 ms | 10604 KB | Output is correct |
54 | Correct | 107 ms | 14956 KB | Output is correct |
55 | Correct | 249 ms | 28012 KB | Output is correct |
56 | Correct | 274 ms | 30316 KB | Output is correct |
57 | Correct | 102 ms | 10604 KB | Output is correct |
58 | Correct | 1 ms | 492 KB | Output is correct |
59 | Correct | 1 ms | 492 KB | Output is correct |
60 | Correct | 1 ms | 492 KB | Output is correct |
61 | Correct | 63 ms | 7916 KB | Output is correct |
62 | Correct | 254 ms | 27372 KB | Output is correct |
63 | Correct | 268 ms | 24940 KB | Output is correct |
64 | Correct | 280 ms | 30444 KB | Output is correct |
65 | Correct | 1 ms | 620 KB | Output is correct |
66 | Correct | 63 ms | 7916 KB | Output is correct |
67 | Correct | 256 ms | 26860 KB | Output is correct |
68 | Correct | 247 ms | 27884 KB | Output is correct |
69 | Correct | 265 ms | 31724 KB | Output is correct |
70 | Correct | 1 ms | 492 KB | Output is correct |
71 | Correct | 1 ms | 620 KB | Output is correct |
72 | Correct | 1 ms | 620 KB | Output is correct |
73 | Correct | 62 ms | 8172 KB | Output is correct |
74 | Correct | 251 ms | 28772 KB | Output is correct |
75 | Correct | 254 ms | 28396 KB | Output is correct |
76 | Correct | 260 ms | 28268 KB | Output is correct |
77 | Correct | 244 ms | 24428 KB | Output is correct |
78 | Correct | 1 ms | 492 KB | Output is correct |
79 | Correct | 1 ms | 620 KB | Output is correct |
80 | Correct | 6 ms | 2028 KB | Output is correct |
81 | Correct | 140 ms | 21100 KB | Output is correct |
82 | Correct | 1 ms | 620 KB | Output is correct |
83 | Correct | 1 ms | 620 KB | Output is correct |
84 | Correct | 1 ms | 620 KB | Output is correct |
85 | Correct | 66 ms | 8172 KB | Output is correct |
86 | Correct | 105 ms | 15084 KB | Output is correct |
87 | Correct | 108 ms | 14444 KB | Output is correct |
88 | Correct | 102 ms | 14444 KB | Output is correct |
89 | Correct | 101 ms | 10752 KB | Output is correct |
90 | Correct | 1 ms | 492 KB | Output is correct |
91 | Correct | 1 ms | 492 KB | Output is correct |
92 | Correct | 5 ms | 876 KB | Output is correct |
93 | Correct | 110 ms | 10416 KB | Output is correct |
94 | Correct | 1 ms | 492 KB | Output is correct |
95 | Correct | 1 ms | 492 KB | Output is correct |
96 | Correct | 1 ms | 492 KB | Output is correct |
97 | Correct | 32 ms | 3052 KB | Output is correct |
98 | Correct | 110 ms | 10672 KB | Output is correct |
99 | Correct | 101 ms | 10476 KB | Output is correct |
100 | Correct | 100 ms | 10476 KB | Output is correct |
101 | Correct | 99 ms | 10348 KB | Output is correct |
102 | Correct | 99 ms | 10476 KB | Output is correct |
103 | Correct | 98 ms | 10348 KB | Output is correct |
104 | Correct | 108 ms | 10348 KB | Output is correct |
105 | Correct | 104 ms | 10348 KB | Output is correct |