# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1050083 | 2024-08-09T07:16:10 Z | noyancanturk | Connecting Supertrees (IOI20_supertrees) | C++17 | 113 ms | 26196 KB |
#include "supertrees.h" #include<bits/stdc++.h> using namespace std; const int lim=2000; #define pb push_back int n; bool used[lim]; vector<vector<int>>comps,need,ans; bool buildcomp(vector<int>&v){ unordered_set<int>myguys; for(int i=0;i<v.size();i++){ myguys.insert(v[i]); } for(int i=0;i<v.size();i++){ for(int j=0;j<n;j++){ if(need[v[i]][j]&&!myguys.count(j))return 0; if(!need[v[i]][j]&&myguys.count(j))return 0; } } vector<int>loop; vector<vector<int>>chains; for(int node:v){ if(!used[node]){ used[node]=1; chains.pb({}); for(int i=0;i<n;i++){ if(need[node][i]==1){ chains.back().pb(i); used[i]=1; } } } } //verify chains for(auto&u:chains){ for(int i=0;i<u.size();i++){ for(int j=0;j<u.size();j++){ if(need[u[i]][u[j]]!=1)return 0; } } } //verify all if(chains.size()==1){ for(int i=0;i+1<chains[0].size();i++){ ans[chains[0][i]][chains[0][i+1]]=ans[chains[0][i+1]][chains[0][i]]=1; } return 1; } if(chains.size()==2){ return 0; } for(int i=0;i<chains.size();i++){ auto&u=chains[i]; for(int j=0;j+1<u.size();j++){ ans[u[j]][u[j+1]]=ans[u[j+1]][u[j]]=1; } if(i)ans[u[0]][chains[i-1][0]]=ans[chains[i-1][0]][u[0]]=1; else ans[u[0]][chains.back()[0]]=ans[chains.back()[0]][u[0]]=1; } return 1; } int construct(std::vector<std::vector<int>> p) { need=p; n = p.size(); for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(p[i][j]==3)return 0; } if(!used[i]){ comps.pb({}); for(int j=0;j<n;j++){ if(p[i][j]){ if(used[j])return 0; comps.back().pb(j); used[j]=1; } } } ans.pb(vector<int>(n,0)); } memset(used,0,n); for(int i=0;i<comps.size();i++){ if(!buildcomp(comps[i])){ return 0; } } build(ans); return 1; } /* int construct(std::vector<std::vector<int>> p) { int n = p.size(); std::vector<std::vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row; row.resize(n); answer.push_back(row); } build(answer); return 1; } */
Compilation message
# | 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 | 1 ms | 348 KB | Output is correct |
6 | Correct | 4 ms | 1372 KB | Output is correct |
7 | Correct | 108 ms | 26132 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 | 1 ms | 348 KB | Output is correct |
6 | Correct | 4 ms | 1372 KB | Output is correct |
7 | Correct | 108 ms | 26132 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 | 348 KB | Output is correct |
12 | Correct | 6 ms | 1372 KB | Output is correct |
13 | Correct | 94 ms | 26196 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 2 ms | 860 KB | Output is correct |
17 | Correct | 46 ms | 12056 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 24 ms | 6888 KB | Output is correct |
21 | Correct | 98 ms | 26112 KB | Output is correct |
22 | Correct | 96 ms | 25940 KB | Output is correct |
23 | Correct | 102 ms | 26120 KB | Output is correct |
24 | Correct | 95 ms | 26196 KB | Output is correct |
25 | Correct | 45 ms | 16164 KB | Output is correct |
26 | Correct | 41 ms | 13392 KB | Output is correct |
27 | Correct | 113 ms | 26196 KB | Output is correct |
28 | Correct | 104 ms | 26192 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 | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 4 ms | 1372 KB | Output is correct |
9 | Correct | 102 ms | 26112 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 4 ms | 1372 KB | Output is correct |
13 | Correct | 98 ms | 26136 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 344 KB | Output is correct |
16 | Correct | 2 ms | 860 KB | Output is correct |
17 | Correct | 45 ms | 12056 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 | 25 ms | 6816 KB | Output is correct |
22 | Correct | 97 ms | 26104 KB | Output is correct |
23 | Correct | 96 ms | 25940 KB | Output is correct |
24 | Correct | 103 ms | 25936 KB | Output is correct |
25 | Correct | 44 ms | 16212 KB | Output is correct |
26 | Correct | 44 ms | 16208 KB | Output is correct |
27 | Correct | 95 ms | 25924 KB | Output is correct |
28 | Correct | 104 ms | 26000 KB | Output is correct |
29 | Correct | 45 ms | 16208 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | 24 ms | 6720 KB | Output is correct |
5 | Correct | 102 ms | 26120 KB | Output is correct |
6 | Correct | 95 ms | 26136 KB | Output is correct |
7 | Correct | 104 ms | 26140 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 26 ms | 6672 KB | Output is correct |
10 | Correct | 99 ms | 25952 KB | Output is correct |
11 | Correct | 97 ms | 25940 KB | Output is correct |
12 | Correct | 102 ms | 26136 KB | Output is correct |
13 | Correct | 0 ms | 344 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 436 KB | Output is correct |
16 | Correct | 26 ms | 6748 KB | Output is correct |
17 | Correct | 100 ms | 26056 KB | Output is correct |
18 | Correct | 105 ms | 25940 KB | Output is correct |
19 | Correct | 99 ms | 26056 KB | Output is correct |
20 | Correct | 95 ms | 26196 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 | 1 ms | 348 KB | Output is correct |
6 | Correct | 4 ms | 1372 KB | Output is correct |
7 | Correct | 108 ms | 26132 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 | 348 KB | Output is correct |
12 | Correct | 6 ms | 1372 KB | Output is correct |
13 | Correct | 94 ms | 26196 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 2 ms | 860 KB | Output is correct |
17 | Correct | 46 ms | 12056 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 24 ms | 6888 KB | Output is correct |
21 | Correct | 98 ms | 26112 KB | Output is correct |
22 | Correct | 96 ms | 25940 KB | Output is correct |
23 | Correct | 102 ms | 26120 KB | Output is correct |
24 | Correct | 95 ms | 26196 KB | Output is correct |
25 | Correct | 45 ms | 16164 KB | Output is correct |
26 | Correct | 41 ms | 13392 KB | Output is correct |
27 | Correct | 113 ms | 26196 KB | Output is correct |
28 | Correct | 104 ms | 26192 KB | Output is correct |
29 | Correct | 0 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 | 4 ms | 1372 KB | Output is correct |
37 | Correct | 102 ms | 26112 KB | Output is correct |
38 | Correct | 0 ms | 348 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
40 | Correct | 4 ms | 1372 KB | Output is correct |
41 | Correct | 98 ms | 26136 KB | Output is correct |
42 | Correct | 0 ms | 344 KB | Output is correct |
43 | Correct | 0 ms | 344 KB | Output is correct |
44 | Correct | 2 ms | 860 KB | Output is correct |
45 | Correct | 45 ms | 12056 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 | 25 ms | 6816 KB | Output is correct |
50 | Correct | 97 ms | 26104 KB | Output is correct |
51 | Correct | 96 ms | 25940 KB | Output is correct |
52 | Correct | 103 ms | 25936 KB | Output is correct |
53 | Correct | 44 ms | 16212 KB | Output is correct |
54 | Correct | 44 ms | 16208 KB | Output is correct |
55 | Correct | 95 ms | 25924 KB | Output is correct |
56 | Correct | 104 ms | 26000 KB | Output is correct |
57 | Correct | 45 ms | 16208 KB | Output is correct |
58 | Correct | 0 ms | 348 KB | Output is correct |
59 | Correct | 0 ms | 348 KB | Output is correct |
60 | Correct | 2 ms | 860 KB | Output is correct |
61 | Correct | 44 ms | 12116 KB | Output is correct |
62 | Correct | 0 ms | 348 KB | Output is correct |
63 | Correct | 0 ms | 348 KB | Output is correct |
64 | Correct | 0 ms | 348 KB | Output is correct |
65 | Correct | 25 ms | 6896 KB | Output is correct |
66 | Correct | 43 ms | 16212 KB | Output is correct |
67 | Correct | 56 ms | 16212 KB | Output is correct |
68 | Correct | 53 ms | 16208 KB | Output is correct |
69 | Correct | 46 ms | 16208 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 | 1 ms | 348 KB | Output is correct |
6 | Correct | 4 ms | 1372 KB | Output is correct |
7 | Correct | 108 ms | 26132 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 | 348 KB | Output is correct |
12 | Correct | 6 ms | 1372 KB | Output is correct |
13 | Correct | 94 ms | 26196 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 2 ms | 860 KB | Output is correct |
17 | Correct | 46 ms | 12056 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 24 ms | 6888 KB | Output is correct |
21 | Correct | 98 ms | 26112 KB | Output is correct |
22 | Correct | 96 ms | 25940 KB | Output is correct |
23 | Correct | 102 ms | 26120 KB | Output is correct |
24 | Correct | 95 ms | 26196 KB | Output is correct |
25 | Correct | 45 ms | 16164 KB | Output is correct |
26 | Correct | 41 ms | 13392 KB | Output is correct |
27 | Correct | 113 ms | 26196 KB | Output is correct |
28 | Correct | 104 ms | 26192 KB | Output is correct |
29 | Correct | 0 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 | 4 ms | 1372 KB | Output is correct |
37 | Correct | 102 ms | 26112 KB | Output is correct |
38 | Correct | 0 ms | 348 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
40 | Correct | 4 ms | 1372 KB | Output is correct |
41 | Correct | 98 ms | 26136 KB | Output is correct |
42 | Correct | 0 ms | 344 KB | Output is correct |
43 | Correct | 0 ms | 344 KB | Output is correct |
44 | Correct | 2 ms | 860 KB | Output is correct |
45 | Correct | 45 ms | 12056 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 | 25 ms | 6816 KB | Output is correct |
50 | Correct | 97 ms | 26104 KB | Output is correct |
51 | Correct | 96 ms | 25940 KB | Output is correct |
52 | Correct | 103 ms | 25936 KB | Output is correct |
53 | Correct | 44 ms | 16212 KB | Output is correct |
54 | Correct | 44 ms | 16208 KB | Output is correct |
55 | Correct | 95 ms | 25924 KB | Output is correct |
56 | Correct | 104 ms | 26000 KB | Output is correct |
57 | Correct | 45 ms | 16208 KB | Output is correct |
58 | Correct | 0 ms | 344 KB | Output is correct |
59 | Correct | 0 ms | 348 KB | Output is correct |
60 | Correct | 0 ms | 348 KB | Output is correct |
61 | Correct | 24 ms | 6720 KB | Output is correct |
62 | Correct | 102 ms | 26120 KB | Output is correct |
63 | Correct | 95 ms | 26136 KB | Output is correct |
64 | Correct | 104 ms | 26140 KB | Output is correct |
65 | Correct | 0 ms | 344 KB | Output is correct |
66 | Correct | 26 ms | 6672 KB | Output is correct |
67 | Correct | 99 ms | 25952 KB | Output is correct |
68 | Correct | 97 ms | 25940 KB | Output is correct |
69 | Correct | 102 ms | 26136 KB | Output is correct |
70 | Correct | 0 ms | 344 KB | Output is correct |
71 | Correct | 0 ms | 348 KB | Output is correct |
72 | Correct | 0 ms | 436 KB | Output is correct |
73 | Correct | 26 ms | 6748 KB | Output is correct |
74 | Correct | 100 ms | 26056 KB | Output is correct |
75 | Correct | 105 ms | 25940 KB | Output is correct |
76 | Correct | 99 ms | 26056 KB | Output is correct |
77 | Correct | 95 ms | 26196 KB | Output is correct |
78 | Correct | 0 ms | 348 KB | Output is correct |
79 | Correct | 0 ms | 348 KB | Output is correct |
80 | Correct | 2 ms | 860 KB | Output is correct |
81 | Correct | 44 ms | 12116 KB | Output is correct |
82 | Correct | 0 ms | 348 KB | Output is correct |
83 | Correct | 0 ms | 348 KB | Output is correct |
84 | Correct | 0 ms | 348 KB | Output is correct |
85 | Correct | 25 ms | 6896 KB | Output is correct |
86 | Correct | 43 ms | 16212 KB | Output is correct |
87 | Correct | 56 ms | 16212 KB | Output is correct |
88 | Correct | 53 ms | 16208 KB | Output is correct |
89 | Correct | 46 ms | 16208 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 | 44 ms | 12048 KB | Output is correct |
94 | Correct | 0 ms | 348 KB | Output is correct |
95 | Correct | 0 ms | 348 KB | Output is correct |
96 | Correct | 0 ms | 348 KB | Output is correct |
97 | Correct | 10 ms | 3480 KB | Output is correct |
98 | Correct | 44 ms | 12408 KB | Output is correct |
99 | Correct | 48 ms | 12624 KB | Output is correct |
100 | Correct | 41 ms | 12372 KB | Output is correct |
101 | Correct | 41 ms | 13592 KB | Output is correct |
102 | Correct | 48 ms | 12060 KB | Output is correct |
103 | Correct | 42 ms | 12116 KB | Output is correct |
104 | Correct | 40 ms | 12116 KB | Output is correct |
105 | Correct | 46 ms | 12112 KB | Output is correct |