Hello everyone, can anyone help me solve this problem using DSU? It would be more great if you do some modifications in my code only. Thanks. i know my code is wrong largely but please help me. https://ideone.com/Bwwo5x https://codeforces.net/contest/277/problem/A
Sorry bro, I couldn't read your code. But I can explain solution with dsu.
You should create graph and find the number of different parent values.
I solved this problem with dfs to count the number of separate graphs
My Solution