514 - Rails

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

Moderator: Board moderators

sangram
New poster
Posts: 8
Joined: Fri Jun 30, 2006 3:27 pm
Contact:

Thanks!

Post by sangram »

hey that does the job. I had unnecessarily put the condition to check for not putting an endline at the very end ...

had one query ... why does this not give PE? When exactly does some submission count as PE?

Thanks a lot! Spent too much time on a relatively simple problem [:(]
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

The judge has some bugs now ( don't worry, will be fixed ). One of them is PE is given WA.
Ami ekhono shopno dekhi...
HomePage
sangram
New poster
Posts: 8
Joined: Fri Jun 30, 2006 3:27 pm
Contact:

Thanks!

Post by sangram »

Oh ok .. fine.
Also ... one suggestion for the new judge if you can help in that matter ... the old judge used to mail the solutions which I submitted ... was nice to keep track of all the submissions ... is there a similar mechanism which exists for the new judge?
Is this going to be setup soon?
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

It will be available, too. BTW don't forget to remove your code from the board.
Ami ekhono shopno dekhi...
HomePage
mice123456789
New poster
Posts: 12
Joined: Tue Aug 27, 2002 6:09 pm

2nd Sample Input

Post by mice123456789 »

Can someone help me by giving explanation how '5 4 1 2 3' is No. Thanks. :-?
shantanu18
New poster
Posts: 22
Joined: Tue Jul 20, 2010 9:55 pm

Post by shantanu18 »

Your train's coaches are in following order --> 1 2 3 4 5
input-->5 4 1 2 3
coaches #5 so push 1 to 4 in station(stack).
coaches #4 you can get it becoz it is in the top of the station
coaches #1 you can not get it, becoz it is in the bottom of the station
So ans is "No"
Hope this will help!
thebohr
New poster
Posts: 1
Joined: Sat Mar 12, 2011 9:49 am

need help...

Post by thebohr »

hello everyone...
i have build a code to solve this problem 514 - Rails...
while compiling this program i got the test case came true..but i still get WA...here is my code #include <stdio.h>
#include <iostream>
#include <stack>

using namespace std;
stack <int>s;
int i,x,d,perm[1000],n,c;
void awal()
{
while(!s.empty())
{
s.pop();
}
}

void pros()
{
x=0;
for(i=1;i<=n;i++)
{
if(perm[x]==i)
{
x++;
while(!s.empty()&&perm[x]==s.top())
{
s.pop();
x++;
}
} else
{
s.push(i);
}
}
}
void last()
{
if(s.empty())
printf("YES\n");
else
printf("NO\n");
}

int main()
{
while(scanf("%d",&n)&&n)
{
while(scanf("%d",&perm[0]))
{
if(!perm[0])
{
printf("\n");
break;
}
for(i=1;i<n;i++)
scanf("%d",&perm);
awal();
pros();
last();
}
}
return 0;
}
fareed
New poster
Posts: 2
Joined: Tue Mar 29, 2011 2:48 pm

Re: 514 wa

Post by fareed »

I am unable to understand the answer 'NO' in any case. can you please briefly tell how you say e.g 3 1 2 give 'No'.
regards
fareed
New poster
Posts: 2
Joined: Tue Mar 29, 2011 2:48 pm

Re: 514 wa

Post by fareed »

sorry i understood the problem in wrong.
mythnc
New poster
Posts: 2
Joined: Wed Jan 11, 2012 6:37 pm

Re: 514 wa

Post by mythnc »

the problem provide this output format:
#begin
Yes
No

Yes
#end
but the judge wants us to output this format:
#begin
Yes
No

Yes

#end

what a contradiction!
i debug this stupid probelm 1 hr.... :evil:
tiendaotd
New poster
Posts: 12
Joined: Mon Jan 14, 2013 12:21 pm

Re: 514 wa

Post by tiendaotd »

I gonna crazy with the problem about printing new line sign '\n' in this problems. I took me 20 minutes to figure out that I have to print TWO '\n' after the last test.

In ACM contest the last '\n' character of the output file is ignored when compare the user's output and the solution's output. Why not UVA system implement this ? This's not the first problem that I have to deal with "Wrong Answer" response just because print less or extra "\n" at the end :evil:
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 514 wa

Post by brianfry713 »

From the problem statement "In addition, there is one empty line after the lines corresponding to one block of the input file." That means there should be a blank line following the last line of the output. If the problem statement says the should be a newline between output blocks, then don't print an extra blank line at the end of the output. A missing or extra newline will result in WA. A missing or extra space may result in PE, but don't count on it.
Check input and AC output for thousands of problems on uDebug!
nazmus_20000
New poster
Posts: 7
Joined: Fri Dec 14, 2012 9:01 pm

514

Post by nazmus_20000 »

Can anyone explain this test case...
5 6 4 8 7 3 2 9 1 10
yes
lbv
Experienced poster
Posts: 128
Joined: Tue Nov 29, 2011 8:40 am

Re: 514

Post by lbv »

nazmus_20000 wrote:Can anyone explain this test case...
5 6 4 8 7 3 2 9 1 10
yes
I suggest you start by reading the problem statement again. Take your time and read it carefully as many times as necessary until you're confident you understand every detail.

Now, as for the test case you mention, consider this sequence of steps:

Code: Select all

              <--- B                      <--- A
 step                       station
==========================================================
    1                                1 2 3 4 5 6 7 8 9 10
 // starting scenario
----------------------------------------------------------
    2                                6 7 8 9 10
                                5
                                4
                                3
                                2
                                1
 // moved 5 from A to station
----------------------------------------------------------
    3   5                            6 7 8 9 10
                                4
                                3
                                2
                                1
 // moved 1 from station to B
----------------------------------------------------------
    4   5 6                          7 8 9 10
                                4
                                3
                                2
                                1
 // moved 1 from A to B
----------------------------------------------------------
    5   5 6 4                        7 8 9 10
                                3
                                2
                                1
 // moved 1 from station to B
----------------------------------------------------------
    6   5 6 4                        9 10
                                8
                                7
                                3
                                2
                                1
 // moved 2 from A to station
----------------------------------------------------------
    7   5 6 4 8 7 3 2                9 10
                                1
 // moved 4 from station to B
----------------------------------------------------------
    8   5 6 4 8 7 3 2 9               10
                                1
 // moved 1 from A to B

.
.
.

the last 2 steps left as an exercise :)
nazmus_20000
New poster
Posts: 7
Joined: Fri Dec 14, 2012 9:01 pm

Re: 514 wa

Post by nazmus_20000 »

Thank u so much IVB.....for your help.....i skipped some point.....now its AC>.....
Post Reply

Return to “Volume 5 (500-599)”