10423 - Peter Takes a Tramway

All about problems in Volume 104. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
zsepi
Learning poster
Posts: 51
Joined: Thu Sep 26, 2002 7:43 pm
Location: Easton, PA, USA

10423 - Peter Takes a Tramway

Post 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
Dealing with failure is easy: Work hard to improve.
Success is also easy to handle: You've solved the wrong problem. Work hard to improve.
Larry
Guru
Posts: 647
Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:

Post 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..
anupam
A great helper
Posts: 405
Joined: Wed Aug 28, 2002 6:45 pm
Contact:

Post by anupam »

i have similar problems...
:oops: :oops: :oops:
"Everything should be made simple, but not always simpler"
zsepi
Learning poster
Posts: 51
Joined: Thu Sep 26, 2002 7:43 pm
Location: Easton, PA, USA

Post 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...
Dealing with failure is easy: Work hard to improve.
Success is also easy to handle: You've solved the wrong problem. Work hard to improve.
Larry
Guru
Posts: 647
Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:

Post 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.
shitty_Mishka
New poster
Posts: 2
Joined: Sun Feb 02, 2003 9:56 pm
Location: Ukraine, Kyiv
Contact:

One more thing...

Post 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.
Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post 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
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey »

Thanks Larry, I was suffering from the 'off by one' problem :oops: :oops: 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... :cry:
Post Reply

Return to “Volume 104 (10400-10499)”