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 1709. Penguin-Avia

wa #1
Posted by hyesun 22 Apr 2014 13:21
I am wondering why i got wa on test #1.
I use dfs to color the edges. when one edge is not colored it means it makes a cycle and thus should be deleted. Next, every time I make dfs with a vertex, I connect it to a vertex processed before, which means the current vertex is connected to a component marked before.
Lastly I used long long to store the result.
But I just got wa on test #1.
Can anybody please tell me sth about test #1 ?
Lots of thanks
Re: wa #1
Posted by hyesun 22 Apr 2014 16:25
Oh damn it.
My first version of code is:
              int d, a, countd, counta;
                    ......
              long long money = d * countd + a * counta;

But I didn't realize that d * countd may have already overflowed.
So my AC version is:
              long long d, a, countd, count;
                     ......
              long long money = .....;
Thus if anyone got WA at test #1 and you are sure you have the right algo, you may have failed due to the same reason as mine.