problem link: http://www.spoj.com/problems/FOXLINGS/en/
AC code: https://ideone.com/eLzUiU WA code: https://ideone.com/Z7d6qy
In my WA code i declared- ll node, edge, par[300005]; Same code I declared like- ll par[300005], node, edge; and got AC...
I can't figure out what's the difference between these two declaration..help please.
It might come down to line 37
for(int i = 1; i <= 300005; i++){ par[i] = i; }
You have only reserved the memory for 0 to 300004 with your ll par[300005] declaration so the code could overwrite other variables you have used and lead to unpredictable results. See if the WA case works if you change the i<=300005 to i<300005.
But in my AC code I used the same i<=300005... got ac just by changing (ll par[300005], node, edge;) from (ll node, edge, par[300005];) Can you tell me why this happened. This declaration should also get WA if there was any unpredictable results issue. :/
That's what unpredictable means. It isn't guaranteed to fail in predictable manner.