# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
825364 | 2023-08-14T18:38:31 Z | HorizonWest | Connecting Supertrees (IOI20_supertrees) | C++17 | 188 ms | 24012 KB |
#include "supertrees.h" #include <vector> #include<bits/stdc++.h> using namespace std; struct st { vector<int> cad; int findf(int a) { if(a==cad[a])return a; else return cad[a]=findf(cad[a]); } void unionf(int a, int b){ a=findf(a); b=findf(b); if(a!=b){ cad[a]=b; } } st(int n){ cad.resize(2*n); for(int i=0; i<cad.size(); i++) cad[i]=i; } }; int construct(std::vector<std::vector<int>> cad) { int n = cad.size(); std::vector<std::vector<int>> answer(n,vector<int>(n,0LL)); st asdfg(n+1); for(int i=0; i<n; i++) for(int j=0; j<n; j++) if(cad[i][j]!=0&&i!=j) asdfg.unionf(i,j); for(int i=0; i<n; i++) for(int j=0; j<n; j++) if(cad[i][j]==0&&asdfg.findf(i)==asdfg.findf(j)&&i!=j) return 0; st asd(n+1); for(int i=0; i<n; i++) for(int j=0; j<n; j++) if(cad[i][j]==1&&i!=j) asd.unionf(i,j); for(int i=0; i<n; i++) for(int j=0; j<n; j++) { if(cad[i][j]==2&&asd.findf(i)==asd.findf(j)&&i!=j) return 0; if(asd.cad[i]==j&&i!=j) { answer[i][j]=1; answer[j][i]=1; } } int v2[n+1]={ }; int v[n+1]={ }; for(int j=0; j<n; j++) { int p=asd.findf(j); if(v[p]==0) { int pg=p; v[p]=1; for(int i=j+1; i<n; i++) { if(v[asd.findf(i)]==0&&asdfg.findf(i)==asdfg.findf(p)) { answer[asd.findf(i)][p]=1; answer[p][asd.findf(i)]=1; p=asd.findf(i); v[asd.findf(i)]=1; v2[asdfg.findf(i)]++; } } if(pg!=p) { answer[pg][p]=1; answer[p][pg]=1; } } } /*for(int i=0; i<n; i++) { if(v2[asdfg.findf(i)]==1) return 0; }*/ build(answer); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 6 ms | 1160 KB | Output is correct |
7 | Correct | 188 ms | 22016 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 6 ms | 1160 KB | Output is correct |
7 | Correct | 188 ms | 22016 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 6 ms | 1108 KB | Output is correct |
13 | Correct | 147 ms | 22024 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 4 ms | 724 KB | Output is correct |
17 | Correct | 66 ms | 12036 KB | Output is correct |
18 | Correct | 0 ms | 284 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 37 ms | 5780 KB | Output is correct |
21 | Correct | 150 ms | 21944 KB | Output is correct |
22 | Correct | 146 ms | 22032 KB | Output is correct |
23 | Correct | 154 ms | 22024 KB | Output is correct |
24 | Correct | 177 ms | 22020 KB | Output is correct |
25 | Correct | 57 ms | 12044 KB | Output is correct |
26 | Correct | 55 ms | 12048 KB | Output is correct |
27 | Correct | 154 ms | 22020 KB | Output is correct |
28 | Correct | 149 ms | 22012 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Incorrect | 0 ms | 212 KB | Answer gives possible 1 while actual possible 0 |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 38 ms | 5716 KB | Output is correct |
5 | Correct | 151 ms | 22032 KB | Output is correct |
6 | Correct | 151 ms | 22068 KB | Output is correct |
7 | Correct | 154 ms | 22016 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 42 ms | 5808 KB | Output is correct |
10 | Correct | 151 ms | 22028 KB | Output is correct |
11 | Correct | 174 ms | 22016 KB | Output is correct |
12 | Correct | 157 ms | 22076 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 46 ms | 6260 KB | Output is correct |
17 | Correct | 162 ms | 23916 KB | Output is correct |
18 | Correct | 153 ms | 23940 KB | Output is correct |
19 | Correct | 150 ms | 23920 KB | Output is correct |
20 | Correct | 168 ms | 24012 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 6 ms | 1160 KB | Output is correct |
7 | Correct | 188 ms | 22016 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 6 ms | 1108 KB | Output is correct |
13 | Correct | 147 ms | 22024 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 4 ms | 724 KB | Output is correct |
17 | Correct | 66 ms | 12036 KB | Output is correct |
18 | Correct | 0 ms | 284 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 37 ms | 5780 KB | Output is correct |
21 | Correct | 150 ms | 21944 KB | Output is correct |
22 | Correct | 146 ms | 22032 KB | Output is correct |
23 | Correct | 154 ms | 22024 KB | Output is correct |
24 | Correct | 177 ms | 22020 KB | Output is correct |
25 | Correct | 57 ms | 12044 KB | Output is correct |
26 | Correct | 55 ms | 12048 KB | Output is correct |
27 | Correct | 154 ms | 22020 KB | Output is correct |
28 | Correct | 149 ms | 22012 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 212 KB | Output is correct |
32 | Incorrect | 0 ms | 212 KB | Answer gives possible 1 while actual possible 0 |
33 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 6 ms | 1160 KB | Output is correct |
7 | Correct | 188 ms | 22016 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 6 ms | 1108 KB | Output is correct |
13 | Correct | 147 ms | 22024 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 4 ms | 724 KB | Output is correct |
17 | Correct | 66 ms | 12036 KB | Output is correct |
18 | Correct | 0 ms | 284 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 37 ms | 5780 KB | Output is correct |
21 | Correct | 150 ms | 21944 KB | Output is correct |
22 | Correct | 146 ms | 22032 KB | Output is correct |
23 | Correct | 154 ms | 22024 KB | Output is correct |
24 | Correct | 177 ms | 22020 KB | Output is correct |
25 | Correct | 57 ms | 12044 KB | Output is correct |
26 | Correct | 55 ms | 12048 KB | Output is correct |
27 | Correct | 154 ms | 22020 KB | Output is correct |
28 | Correct | 149 ms | 22012 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 212 KB | Output is correct |
32 | Incorrect | 0 ms | 212 KB | Answer gives possible 1 while actual possible 0 |
33 | Halted | 0 ms | 0 KB | - |