ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1587. Flying Pig

Why WA #14
Posted by LittlePig 28 Oct 2007 13:50
Help me, please.. Thanks..
Re: Why WA #14
Posted by svr 29 Oct 2007 22:10
Because you passed 14 test with BigNum you is Ok therefore
you have problem with logic of the task.
In this situation simple but clever test may help
and they easy to produce if having AC.
Try the next:
15
1 -1 0 2 -2 0 3 -1 0 0 -3 -3 2 0 1
Ans=18
and this one:
11
-1 0 -1 0 -3 0 -1 0 0 0 -2
Ans=0

Edited by author 29.10.2007 22:39
Re: Why WA #14
Posted by Giorgi Saghinadze (Tbilisi SU) 30 Oct 2007 15:42
I used big numbers only for printing answer.
I like my solution :)
Re: Why WA #14
Posted by Denis Koshman 20 Jul 2008 19:25
Got WA14 too... But currently I use big numbers for temporary calculations.
Re: Why WA #14
Posted by Denis Koshman 20 Jul 2008 19:36
Got AC. The problem was with long arithmetics. I wrote it modulo 10000, and it started overflowing after squaring because number of digits also must be taken into consideration. After reverting to modulo 1000, it worked fine.

Try test with 50000 of 3s, check if you do not get negatives in the answer.