Блог пользователя Legendary_Expert

Автор Legendary_Expert, история, 8 лет назад, По-английски

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.

  • Проголосовать: нравится
  • -13
  • Проголосовать: не нравится

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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.