That's what I did too. The only problem is that building the graph is not linear time, I believe. Still, it was fast enough to get it accepted in 0.012s.roticv wrote:I finally realised that there is a linear solution to the problem - solving longest path on a DAG.
Search found 6 matches
- Mon Dec 10, 2012 10:46 am
- Forum: Volume 4 (400-499)
- Topic: 437 - The Tower of Babylon
- Replies: 14
- Views: 9753
Re: 437 - Any good idea for Towers of Babylonia?
- Wed Dec 05, 2012 12:59 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10099 - The Tourist Guide
- Replies: 91
- Views: 43153
Re: 10099 - The Tourist Guide
Have you actually check the sample input/output? You code produces
Minimun Number of Trips = 4
when it should be
Minimun Number of Trips = 5
Anyways, your error is in the line with the division and ceiling in the output. 99/24 = 4 since it is an integer division, so ceiling is useless.
Minimun Number of Trips = 4
when it should be
Minimun Number of Trips = 5
Anyways, your error is in the line with the division and ceiling in the output. 99/24 = 4 since it is an integer division, so ceiling is useless.
- Tue Dec 04, 2012 6:21 am
- Forum: Volume 5 (500-599)
- Topic: 545 - Heads
- Replies: 67
- Views: 54507
Re: 545
I honestly do not know what's wrong with my code. I used the square and double method, which worked perfectly well on 474, and is failing hard here. Eventually I took the suggestion of using BigInt, and got it accepted. I still have no idea what's wrong though, since both code gives the same output ...
- Tue Dec 04, 2012 5:26 am
- Forum: Volume 4 (400-499)
- Topic: 474 - Heads / Tails Probability
- Replies: 50
- Views: 18485
Re: 474 problem
I don't think so. My AC code outputs 2^-6 = 1.563e-2.
- Sun Dec 02, 2012 2:22 am
- Forum: Volume 7 (700-799)
- Topic: 793 - Network Connections
- Replies: 102
- Views: 47741
Re: 793 - Network Connections
I hate print blank line between test case so much. Judge will say WA instead of PE, which leads you to a wild goose chase.
- Mon Nov 26, 2012 7:40 am
- Forum: Volume 100 (10000-10099)
- Topic: 10067 - Playing with Wheels
- Replies: 62
- Views: 35456
Re: 10067 - Playing with Wheels
On this case:
1
9 9 9 9
0 0 0 0
1
9 9 9 9
The code I just submitted and got AC with returns -1, if you'd rather believe your WA code and UVAtoolkit's 4 that's up to you, let us know if you can get AC with that logic. Others in this thread that have got AC agreed that it should be -1.
My AC code ...
1
9 9 9 9
0 0 0 0
1
9 9 9 9
The code I just submitted and got AC with returns -1, if you'd rather believe your WA code and UVAtoolkit's 4 that's up to you, let us know if you can get AC with that logic. Others in this thread that have got AC agreed that it should be -1.
My AC code ...