# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
587788 | 2022-07-02T11:18:50 Z | almothana05 | Connecting Supertrees (IOI20_supertrees) | C++14 | 247 ms | 22620 KB |
#include "supertrees.h" #include <vector> #include<bits/stdc++.h> using namespace std; vector<vector<int> >erg; vector<int>cmp[2000] , comp; int vis[2000] , visi[2000] , f[2000]; set<int> s; int construct(vector<vector<int>> p) { int menge = p.size() , pl = 1; for(int i = 0 ; i < menge ; i++){ erg.push_back(vector<int>() ); for(int j = 0 ; j < menge ; j++){ if(p[i][j] == 3){ return 0; } erg[i].push_back(0); } } for(int i = 0 ; i < menge ; i++){ if(p[i][i] != 1){ return 0; } p[i][i] = 1; } for(int i = 0 ; i < menge ; i++){ if(vis[i] == 0){ vis[i] = pl; for(int j = 0 ; j < menge ; j++){ if(p[i][j] == 1){ cmp[pl].push_back(j); vis[j] = pl; } } int fl = 1; for(int j = 0 ; j < menge ; j++){ for(int k = 0 ; k < cmp[pl].size() ; k++){ if(p[i][j] != p[cmp[pl][k]][j]){ fl = 0; break; } } } for(int j = 0 ; j < cmp[pl].size() - 1 ; j++){ erg[cmp[pl][j]][cmp[pl][j + 1]] = 1; erg[cmp[pl][j + 1]][cmp[pl][j]] = 1; } if(fl == 0){ return 0; } f[pl] = i; // cout << pl << " " << i << "\n"; pl++; } } int c = 1; for(int i = 1 ; i < pl; i++){ s.clear(); comp.clear(); int kan = f[i]; if(visi[i] == 0){ visi[i] = c; for(int j = 0 ; j < menge ; j++){ if(p[kan][j] == 2){ // cout << f[vis[j]] << ' ' << i << "\n"; if(s.count(vis[j]) == 0){ assert(i != vis[j]); s.insert(vis[j]); comp.push_back(f[vis[j]]); visi[vis[j]] = c; } } } s.insert(i); int fl = 1; // cout << "yo\n"; comp.push_back(kan); for(int k = 0 ; k < comp.size() ; k++){ for(int j = 0 ; j < menge ; j++){ // if(p[kan][j] == 0 && p[comp[k][j]] != 0){ // return 0; // } // if(p[kan][j] == 0 && p[comp[k][j]] != 0){ // return 0; // } if(p[comp[k]][j] != p[j][comp[k]]){ fl = 0; break; } if(vis[j] != vis[comp[k]] && s.count(vis[j]) == 1 && p[comp[k]][j] != 2){ fl = 0; break; } if(s.count(vis[j]) == 0 && p[comp[k]][j] == 2){ fl = 0; break; } } } if(comp.size() == 2){ return 0; } if(fl == 0){ return 0; } // assert(comp.size() > 2); for(int j = 0 ; j < comp.size() ; j++){ // cout << comp[j] << ' '; if(j != (j + 1) % comp.size()){ erg[comp[j]][comp[(j + 1) % comp.size()]] = 1; erg[comp[(j + 1) % comp.size()] ][comp[j]] = 1; // assert() } } // cout << "\n"; } } build(erg); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 276 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 10 ms | 1236 KB | Output is correct |
7 | Correct | 182 ms | 22204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 276 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 10 ms | 1236 KB | Output is correct |
7 | Correct | 182 ms | 22204 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 10 ms | 1232 KB | Output is correct |
13 | Correct | 183 ms | 22176 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 4 ms | 852 KB | Output is correct |
17 | Correct | 85 ms | 12212 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 43 ms | 5780 KB | Output is correct |
21 | Correct | 171 ms | 22492 KB | Output is correct |
22 | Correct | 183 ms | 22192 KB | Output is correct |
23 | Correct | 186 ms | 22484 KB | Output is correct |
24 | Correct | 220 ms | 22400 KB | Output is correct |
25 | Correct | 81 ms | 12516 KB | Output is correct |
26 | Correct | 95 ms | 12496 KB | Output is correct |
27 | Correct | 216 ms | 22216 KB | Output is correct |
28 | Correct | 187 ms | 22208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 11 ms | 1320 KB | Output is correct |
9 | Correct | 183 ms | 22308 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 10 ms | 1292 KB | Output is correct |
13 | Correct | 235 ms | 22392 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 4 ms | 896 KB | Output is correct |
17 | Correct | 104 ms | 13276 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 0 ms | 340 KB | Output is correct |
21 | Correct | 48 ms | 5856 KB | Output is correct |
22 | Correct | 195 ms | 22344 KB | Output is correct |
23 | Correct | 203 ms | 22392 KB | Output is correct |
24 | Correct | 235 ms | 22368 KB | Output is correct |
25 | Correct | 99 ms | 13308 KB | Output is correct |
26 | Correct | 86 ms | 13296 KB | Output is correct |
27 | Correct | 177 ms | 22356 KB | Output is correct |
28 | Correct | 247 ms | 22344 KB | Output is correct |
29 | Correct | 84 ms | 13288 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 352 KB | Output is correct |
4 | Correct | 45 ms | 6076 KB | Output is correct |
5 | Correct | 178 ms | 22468 KB | Output is correct |
6 | Correct | 172 ms | 22476 KB | Output is correct |
7 | Correct | 197 ms | 22480 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 48 ms | 5836 KB | Output is correct |
10 | Correct | 207 ms | 22200 KB | Output is correct |
11 | Correct | 189 ms | 22484 KB | Output is correct |
12 | Correct | 245 ms | 22620 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 50 ms | 6044 KB | Output is correct |
17 | Correct | 204 ms | 22524 KB | Output is correct |
18 | Correct | 192 ms | 22416 KB | Output is correct |
19 | Correct | 200 ms | 22308 KB | Output is correct |
20 | Correct | 187 ms | 22476 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 276 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 10 ms | 1236 KB | Output is correct |
7 | Correct | 182 ms | 22204 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 10 ms | 1232 KB | Output is correct |
13 | Correct | 183 ms | 22176 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 4 ms | 852 KB | Output is correct |
17 | Correct | 85 ms | 12212 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 43 ms | 5780 KB | Output is correct |
21 | Correct | 171 ms | 22492 KB | Output is correct |
22 | Correct | 183 ms | 22192 KB | Output is correct |
23 | Correct | 186 ms | 22484 KB | Output is correct |
24 | Correct | 220 ms | 22400 KB | Output is correct |
25 | Correct | 81 ms | 12516 KB | Output is correct |
26 | Correct | 95 ms | 12496 KB | Output is correct |
27 | Correct | 216 ms | 22216 KB | Output is correct |
28 | Correct | 187 ms | 22208 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 0 ms | 340 KB | Output is correct |
34 | Correct | 0 ms | 340 KB | Output is correct |
35 | Correct | 0 ms | 340 KB | Output is correct |
36 | Correct | 11 ms | 1320 KB | Output is correct |
37 | Correct | 183 ms | 22308 KB | Output is correct |
38 | Correct | 0 ms | 340 KB | Output is correct |
39 | Correct | 0 ms | 340 KB | Output is correct |
40 | Correct | 10 ms | 1292 KB | Output is correct |
41 | Correct | 235 ms | 22392 KB | Output is correct |
42 | Correct | 0 ms | 340 KB | Output is correct |
43 | Correct | 1 ms | 340 KB | Output is correct |
44 | Correct | 4 ms | 896 KB | Output is correct |
45 | Correct | 104 ms | 13276 KB | Output is correct |
46 | Correct | 0 ms | 340 KB | Output is correct |
47 | Correct | 0 ms | 340 KB | Output is correct |
48 | Correct | 0 ms | 340 KB | Output is correct |
49 | Correct | 48 ms | 5856 KB | Output is correct |
50 | Correct | 195 ms | 22344 KB | Output is correct |
51 | Correct | 203 ms | 22392 KB | Output is correct |
52 | Correct | 235 ms | 22368 KB | Output is correct |
53 | Correct | 99 ms | 13308 KB | Output is correct |
54 | Correct | 86 ms | 13296 KB | Output is correct |
55 | Correct | 177 ms | 22356 KB | Output is correct |
56 | Correct | 247 ms | 22344 KB | Output is correct |
57 | Correct | 84 ms | 13288 KB | Output is correct |
58 | Correct | 1 ms | 340 KB | Output is correct |
59 | Correct | 0 ms | 340 KB | Output is correct |
60 | Correct | 4 ms | 852 KB | Output is correct |
61 | Correct | 99 ms | 13288 KB | Output is correct |
62 | Correct | 0 ms | 340 KB | Output is correct |
63 | Correct | 0 ms | 340 KB | Output is correct |
64 | Correct | 1 ms | 340 KB | Output is correct |
65 | Correct | 49 ms | 5816 KB | Output is correct |
66 | Correct | 78 ms | 13272 KB | Output is correct |
67 | Correct | 93 ms | 13320 KB | Output is correct |
68 | Correct | 77 ms | 13256 KB | Output is correct |
69 | Correct | 78 ms | 13268 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 276 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 10 ms | 1236 KB | Output is correct |
7 | Correct | 182 ms | 22204 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 10 ms | 1232 KB | Output is correct |
13 | Correct | 183 ms | 22176 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 4 ms | 852 KB | Output is correct |
17 | Correct | 85 ms | 12212 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 43 ms | 5780 KB | Output is correct |
21 | Correct | 171 ms | 22492 KB | Output is correct |
22 | Correct | 183 ms | 22192 KB | Output is correct |
23 | Correct | 186 ms | 22484 KB | Output is correct |
24 | Correct | 220 ms | 22400 KB | Output is correct |
25 | Correct | 81 ms | 12516 KB | Output is correct |
26 | Correct | 95 ms | 12496 KB | Output is correct |
27 | Correct | 216 ms | 22216 KB | Output is correct |
28 | Correct | 187 ms | 22208 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 0 ms | 340 KB | Output is correct |
34 | Correct | 0 ms | 340 KB | Output is correct |
35 | Correct | 0 ms | 340 KB | Output is correct |
36 | Correct | 11 ms | 1320 KB | Output is correct |
37 | Correct | 183 ms | 22308 KB | Output is correct |
38 | Correct | 0 ms | 340 KB | Output is correct |
39 | Correct | 0 ms | 340 KB | Output is correct |
40 | Correct | 10 ms | 1292 KB | Output is correct |
41 | Correct | 235 ms | 22392 KB | Output is correct |
42 | Correct | 0 ms | 340 KB | Output is correct |
43 | Correct | 1 ms | 340 KB | Output is correct |
44 | Correct | 4 ms | 896 KB | Output is correct |
45 | Correct | 104 ms | 13276 KB | Output is correct |
46 | Correct | 0 ms | 340 KB | Output is correct |
47 | Correct | 0 ms | 340 KB | Output is correct |
48 | Correct | 0 ms | 340 KB | Output is correct |
49 | Correct | 48 ms | 5856 KB | Output is correct |
50 | Correct | 195 ms | 22344 KB | Output is correct |
51 | Correct | 203 ms | 22392 KB | Output is correct |
52 | Correct | 235 ms | 22368 KB | Output is correct |
53 | Correct | 99 ms | 13308 KB | Output is correct |
54 | Correct | 86 ms | 13296 KB | Output is correct |
55 | Correct | 177 ms | 22356 KB | Output is correct |
56 | Correct | 247 ms | 22344 KB | Output is correct |
57 | Correct | 84 ms | 13288 KB | Output is correct |
58 | Correct | 0 ms | 340 KB | Output is correct |
59 | Correct | 1 ms | 348 KB | Output is correct |
60 | Correct | 1 ms | 352 KB | Output is correct |
61 | Correct | 45 ms | 6076 KB | Output is correct |
62 | Correct | 178 ms | 22468 KB | Output is correct |
63 | Correct | 172 ms | 22476 KB | Output is correct |
64 | Correct | 197 ms | 22480 KB | Output is correct |
65 | Correct | 0 ms | 340 KB | Output is correct |
66 | Correct | 48 ms | 5836 KB | Output is correct |
67 | Correct | 207 ms | 22200 KB | Output is correct |
68 | Correct | 189 ms | 22484 KB | Output is correct |
69 | Correct | 245 ms | 22620 KB | Output is correct |
70 | Correct | 0 ms | 340 KB | Output is correct |
71 | Correct | 1 ms | 340 KB | Output is correct |
72 | Correct | 0 ms | 340 KB | Output is correct |
73 | Correct | 50 ms | 6044 KB | Output is correct |
74 | Correct | 204 ms | 22524 KB | Output is correct |
75 | Correct | 192 ms | 22416 KB | Output is correct |
76 | Correct | 200 ms | 22308 KB | Output is correct |
77 | Correct | 187 ms | 22476 KB | Output is correct |
78 | Correct | 1 ms | 340 KB | Output is correct |
79 | Correct | 0 ms | 340 KB | Output is correct |
80 | Correct | 4 ms | 852 KB | Output is correct |
81 | Correct | 99 ms | 13288 KB | Output is correct |
82 | Correct | 0 ms | 340 KB | Output is correct |
83 | Correct | 0 ms | 340 KB | Output is correct |
84 | Correct | 1 ms | 340 KB | Output is correct |
85 | Correct | 49 ms | 5816 KB | Output is correct |
86 | Correct | 78 ms | 13272 KB | Output is correct |
87 | Correct | 93 ms | 13320 KB | Output is correct |
88 | Correct | 77 ms | 13256 KB | Output is correct |
89 | Correct | 78 ms | 13268 KB | Output is correct |
90 | Correct | 1 ms | 340 KB | Output is correct |
91 | Correct | 0 ms | 340 KB | Output is correct |
92 | Correct | 4 ms | 596 KB | Output is correct |
93 | Correct | 87 ms | 9192 KB | Output is correct |
94 | Correct | 0 ms | 340 KB | Output is correct |
95 | Correct | 0 ms | 340 KB | Output is correct |
96 | Correct | 1 ms | 340 KB | Output is correct |
97 | Correct | 18 ms | 2764 KB | Output is correct |
98 | Correct | 74 ms | 10416 KB | Output is correct |
99 | Correct | 70 ms | 10676 KB | Output is correct |
100 | Correct | 69 ms | 10420 KB | Output is correct |
101 | Correct | 76 ms | 11560 KB | Output is correct |
102 | Correct | 84 ms | 10072 KB | Output is correct |
103 | Correct | 79 ms | 10168 KB | Output is correct |
104 | Correct | 75 ms | 10168 KB | Output is correct |
105 | Correct | 82 ms | 10156 KB | Output is correct |