Page 1 of 1
10423 - Peter Takes a Tramway
Posted: Wed Jan 15, 2003 9:40 am
by zsepi
ok, this problem seemed fairly easy, but I keep on getting WA. Would someone give me a hint about (if there are any) tricky cases? Is there something with the train numbers, for instance, can they be negative or zero? 'coz there is nothing else I can think about.... but then, i have no clue how to proceed... pls, hints, hints, hints!
thanx
Posted: Thu Jan 16, 2003 11:27 pm
by Larry
I had the same problem for awhile.. and then I scraped what I wrote and rewrote everything from scratch and it worked...
There shouldn't be any trick cases, just be careful how you handle off by ones and boundary conditions..
Posted: Fri Jan 17, 2003 2:08 pm
by anupam
Posted: Sat Jan 18, 2003 1:34 am
by zsepi
anupam, I got AC - it is a real frustrating problem! Once I had a physics teacher and noone ever could score 100% on his tests, 'coz he would trick us... for instance, if in class he gave us all data in meters, then he would change it to centimeter in the test or something like that... You just need to read the question and think which tram # it is asking for and which one are you prinitng...
Posted: Sat Jan 18, 2003 3:01 am
by Larry
But there's no "trick" in this problem.. just tons of potential for boundary condition errors.. once again, just be careful how you implement it and it should be okay.
Here's what I used for test cases - it's easy to check them by hand:
Code: Select all
5
1: 58 -1
2: 59 -1
3: 0 -1
4: 1 -1
5: 2 -1
0 1000000
5
1: 58 -1
2: 59 -1
3: 0 -1
4: 1 -1
5: 2 -1
0 1000001
5
1: 58 -1
2: 59 -1
3: 0 -1
4: 1 -1
5: 2 -1
0 1000002
5
1: 58 -1
2: 59 -1
3: 0 -1
4: 1 -1
5: 2 -1
50 1000000
5
1: 58 -1
2: 59 -1
3: 0 -1
4: 1 -1
5: 2 -1
4 1000001
5
1: 58 -1
2: 59 -1
3: 0 -1
4: 1 -1
5: 2 -1
6 1000002
0
And I get:
Code: Select all
Case 1: Peter arrives at stop 1000000 by tram 2.
Case 2: Peter arrives at stop 1000001 by tram 3.
Case 3: Peter arrives at stop 1000002 by tram 4.
Case 4: Peter arrives at stop 1000000 by tram 5.
Case 5: Peter arrives at stop 1000001 by tram 1.
Case 6: Peter arrives at stop 1000002 by tram 2.
One more thing...
Posted: Sun Feb 02, 2003 9:59 pm
by shitty_Mishka
Mind that in this problem you will get no P.E.. Well, maybe you can, but I forgot only to put a fullstop (".") at the end of every line, and the verdict was WA instead of PE.
Posted: Mon Feb 03, 2003 9:01 am
by Dominik Michniewski
And they have right ...
If you don't put full stop - it's WA, when you use double space instead of one - it's PE
Dominik
Posted: Wed Apr 16, 2003 1:10 pm
by little joey
Thanks Larry, I was suffering from the 'off by one' problem

but your test cases made me see it.
In Holland we have a saying:
A donkey never bumps into the same stone twice.
I must have bumped into the 'off by one' stone at least a million times (especially when doing modular arithmetic), which proves I'm not a donkey

but worse...
