Problem link is here https://codeforces.com/contest/1167/problem/C
I used disjoint union but don't know why the size array converts to zero entry in test case 3 although I initiated it to 1 and did only addition. Thank You.
# | User | Rating |
---|---|---|
1 | jiangly | 3640 |
2 | Benq | 3593 |
3 | tourist | 3572 |
4 | orzdevinwang | 3561 |
5 | cnnfls_csy | 3539 |
6 | ecnerwala | 3534 |
7 | Radewoosh | 3532 |
8 | gyh20 | 3447 |
9 | Rebelz | 3409 |
10 | Geothermal | 3408 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 173 |
2 | adamant | 164 |
3 | awoo | 162 |
4 | TheScrasse | 160 |
5 | nor | 159 |
6 | maroonrk | 156 |
7 | SecondThread | 154 |
8 | pajenegod | 147 |
9 | Um_nik | 145 |
9 | BledDest | 145 |
Problem link is here https://codeforces.com/contest/1167/problem/C
I used disjoint union but don't know why the size array converts to zero entry in test case 3 although I initiated it to 1 and did only addition. Thank You.
Name |
---|
Do not reconnect two people who are already in the same connected component. Only connect them if they are not already connected. You can easily check this by the find operation.
You're merging two sets even when they represent the same set. I added two lines to your code and it gets accepted.