514 wa

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

Moderator: Board moderators

Thanks!

Postby sangram » Thu Sep 20, 2007 4:14 pm

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 [:(]
sangram
New poster
 
Posts: 8
Joined: Fri Jun 30, 2006 3:27 pm

Postby Jan » Thu Sep 20, 2007 4:21 pm

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
Jan
Guru
 
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh

Thanks!

Postby sangram » Thu Sep 20, 2007 4:30 pm

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?
sangram
New poster
 
Posts: 8
Joined: Fri Jun 30, 2006 3:27 pm

Postby Jan » Thu Sep 20, 2007 4:38 pm

It will be available, too. BTW don't forget to remove your code from the board.
Ami ekhono shopno dekhi...
HomePage
Jan
Guru
 
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh

2nd Sample Input

Postby mice123456789 » Tue Sep 08, 2009 6:19 pm

Can someone help me by giving explanation how '5 4 1 2 3' is No. Thanks. :-?
mice123456789
New poster
 
Posts: 12
Joined: Tue Aug 27, 2002 6:09 pm

Postby shantanu18 » Wed Sep 01, 2010 4:24 am

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!
shantanu18
New poster
 
Posts: 22
Joined: Tue Jul 20, 2010 9:55 pm

Re: 514 wa

Postby fareed » Tue Mar 29, 2011 2:51 pm

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

Postby fareed » Tue Mar 29, 2011 3:03 pm

sorry i understood the problem in wrong.
fareed
New poster
 
Posts: 2
Joined: Tue Mar 29, 2011 2:48 pm

Re: 514 wa

Postby mythnc » Thu Jan 12, 2012 5:51 pm

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:
mythnc
New poster
 
Posts: 2
Joined: Wed Jan 11, 2012 6:37 pm

Re: 514 wa

Postby tiendaotd » Mon Jan 14, 2013 1:55 pm

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:
tiendaotd
New poster
 
Posts: 12
Joined: Mon Jan 14, 2013 12:21 pm

Re: 514 wa

Postby brianfry713 » Mon Jan 14, 2013 9:04 pm

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.
brianfry713
Guru
 
Posts: 1765
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

514

Postby nazmus_20000 » Fri Mar 01, 2013 7:05 am

Can anyone explain this test case...
5 6 4 8 7 3 2 9 1 10
yes
nazmus_20000
New poster
 
Posts: 7
Joined: Fri Dec 14, 2012 9:01 pm

Re: 514

Postby lbv » Fri Mar 01, 2013 8:05 am

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 :)
lbv
Learning poster
 
Posts: 54
Joined: Tue Nov 29, 2011 8:40 am

Re: 514 wa

Postby nazmus_20000 » Fri Mar 01, 2013 12:31 pm

Thank u so much IVB.....for your help.....i skipped some point.....now its AC>.....
nazmus_20000
New poster
 
Posts: 7
Joined: Fri Dec 14, 2012 9:01 pm

Re: 514 wa

Postby moxlotus » Sat Mar 16, 2013 4:16 pm

Below is my code for this problem.
I have passed all the test cases on this thread but still getting the WA.
Whats wrong with my formatting?? >.<
Code: Select all
import java.util.*;

public class Main{
   public static void main(String[] args){
      Scanner sc=new Scanner(System.in);
      LinkedList<Integer> original;
      LinkedList<Integer> permutation;
      Stack<Integer> stack;
      int noOfCoaches = sc.nextInt();
      boolean match;

      while(noOfCoaches != 0)
      {
         while(true)
         {
            original = new LinkedList<Integer>();
            permutation = new LinkedList<Integer>();
            stack = new Stack<Integer>();
            match = true;
            int num = sc.nextInt();
            if(num == 0)
            {
               System.out.printf("\n");   
               break;
            }
            permutation.offer(num);
            for(int i = 0; i < noOfCoaches; i++)
            {
               original.offer(i+1);
            }
            for(int i = 1; i < noOfCoaches; i++)
            {
               permutation.offer(sc.nextInt());
            }
            while(original.size() > 0 && match)
            {
               stack.push(original.poll());
               while(stack.peek() != permutation.peek() && original.size() > 0)
               {
                  stack.push(original.poll());
               }
               while(!stack.empty() && match)
               {
                  if(stack.peek() == permutation.peek())
                  {
                     stack.pop();
                     permutation.poll();
                  }
                  else if(original.peek() != null)
                  {
                     break;
                  }
                  else
                  {
                     match = false;   
                  }
               }
            }

            if(match) System.out.printf("Yes\n");   
            else System.out.printf("No\n");   
         }
         noOfCoaches = sc.nextInt();
      }   
   }
}


One of the sample input from the here
Code: Select all
5
1 2 3 4 5
5 4 1 2 3
0
6
6 5 4 3 2 1
5 6 4 3 2 1
1 2 3 4 5 6
0
10
1 2 3 4 5 10 9 8 7 6
0
0

Below is my output
Code: Select all
Yes
No

Yes
Yes
Yes

Yes

moxlotus
New poster
 
Posts: 4
Joined: Sat Sep 17, 2011 6:47 am

PreviousNext

Return to Volume V

Who is online

Users browsing this forum: No registered users and 0 guests