# WRONG

solution

I used priority queue to keep shortest at top of the graph and print them according to group number, as group number will be the smallest element in the individual graph, and initially each pq contains one element i.e. itself, and group number as itself, if a link with some other vertex is found with smaller group number, its all elements are transferred to that pq, and in case of duplicate , all of them are removed/ as it failed at test case 8 and 22nd th element is different , and other aren’t visible to me and even if were, making a matrices on copy and solving by pen would be tough , can you please help me figure out whats wrong. Thanks in advance

Though no one helped me, finally solved it myself, though shalln’t answer my own question (maybe), still if it helps someone while googling, i’ll be glad.

1. Create graphs of all connected components (priority queue, with group number of that individual graph as the minimum edge in that particular graph)
1. as using priority queue i.e. pq, all graphs will be sorted.
1. read each edge in permutation and print the minimum in that individual graph (via group number), though all may be connected to single, i.e. in 2nd case.

{help} as if edges have same group numbers (already lie in same graph), will not consider push, this will avoid duplicate and infinite loop i.e. putting and extracting from same graph. and poping out also help avoid duplicate.

# Thanks to me!

2 Likes

why dont u participate in codechef contests ?

1 Like

actually am still scared of them, actually i started with codechef itself, the statements were so tricky, i was scared on asked someone on linkedin for help, he guided me to use codeforces to start, besides test cases are visible (highly helpful for a beginner least). And codechef has a very good friendly community, so i always ask questions here, i tried participatin in contests but couldn’t solve any, once i get average with coding i will surely on all websites like topcoder, codechef etc, though codechef is best, can you please guide me as am alone, what contests to participate as beginner.

Obviously the long contests in codechef.

My case is totally opposite,i am afraid of codeforces(as i felt them too hard),but probably would start doing on it nowonwards.

During long if u dont get something try to google as much as u can.After it ends see the editorials(i prefer unofficial editorials as they are simple).After that solve problems on spoj for the remaining month (it will help u learn fast (really fast) ).Then maybe u can practice dp where i found codeforces the best.

1 Like

@ashigahlawat try Long challenges …
codeforces has very good questions but for a beginner they are quite hard to solve in 2 hours …

1 Like