514 - Rails
Moderator: Board moderators
Thanks!
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 [:(]
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 [:(]
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
HomePage
Thanks!
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?
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?
It will be available, too. BTW don't forget to remove your code from the board.
Ami ekhono shopno dekhi...
HomePage
HomePage
-
- New poster
- Posts: 12
- Joined: Tue Aug 27, 2002 6:09 pm
2nd Sample Input
Can someone help me by giving explanation how '5 4 1 2 3' is No. Thanks.
-
- New poster
- Posts: 22
- Joined: Tue Jul 20, 2010 9:55 pm
need help...
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;
}
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
Code: Select all
#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;
}
Re: 514 wa
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
regards
Re: 514 wa
sorry i understood the problem in wrong.
Re: 514 wa
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....
#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....
Re: 514 wa
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
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
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 514 wa
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!
-
- New poster
- Posts: 7
- Joined: Fri Dec 14, 2012 9:01 pm
514
Can anyone explain this test case...
5 6 4 8 7 3 2 9 1 10
yes
5 6 4 8 7 3 2 9 1 10
yes
Re: 514
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.nazmus_20000 wrote:Can anyone explain this test case...
5 6 4 8 7 3 2 9 1 10
yes
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 :)
-
- New poster
- Posts: 7
- Joined: Fri Dec 14, 2012 9:01 pm
Re: 514 wa
Thank u so much IVB.....for your help.....i skipped some point.....now its AC>.....