231 - Testing the CATCHER

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

Moderator: Board moderators

sun_kuet
New poster
Posts: 12
Joined: Wed Mar 27, 2013 4:28 pm

WA :( plz help.... 231- Testing the CATCHER

Post by sun_kuet » Fri Mar 29, 2013 2:07 am

after accepted i i removed the code
Last edited by sun_kuet on Fri Mar 29, 2013 6:00 pm, edited 1 time in total.

riger400
New poster
Posts: 2
Joined: Thu May 01, 2014 7:50 am

Re: WA 231 Testing the catcher

Post by riger400 » Wed May 14, 2014 11:53 pm

can anyone help me I'm getting WA again and again, here is my code
[/code]

import java.util.*;
import java.io.*;

public class Main{

static int[] motherArray = new int[33000];
static int arrayCounter = 0;

public static void main(String[] args) throws IOException {
BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));
//BufferedReader obj = new BufferedReader(new FileReader("D://uva.txt"));
PrintWriter prin = new PrintWriter(System.out);
String line;
int testCase = 0;
while ((line = obj.readLine()) != null) {
int num = Integer.parseInt(line);
if (num >= 0) {
motherArray[arrayCounter] = num;
arrayCounter++;
} else if (num == -1) {
testCase++;
LIS(testCase);

Arrays.fill(motherArray, 0);
arrayCounter = 0;
}

}
prin.flush();
}

public static void LIS(int test) {
if (arrayCounter == 0) {
return;
}
PrintWriter prin = new PrintWriter(System.out);
String[] length = new String[arrayCounter];
int[] size = new int[arrayCounter];
for (int i = 0; i < arrayCounter; i++) {
size = 1;
length = motherArray + " ";
}
int maxLength = 1;
for (int i = 1; i < arrayCounter; i++) {
for (int j = 0; j < i; j++) {
if (motherArray <= motherArray[j] && size < size[j] + 1) {
size = size[j] + 1;
length = length[j] + motherArray + " ";
if (maxLength < size) {
maxLength = size;
}
}
}
}
String line = "";

prin.println("Test #" + test + ":");
prin.println(" maximum possible interceptions: " + maxLength);
prin.println();
prin.flush();
}
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: WA 231 Testing the catcher

Post by brianfry713 » Thu May 15, 2014 8:29 pm

There should be two spaces before maximum.
Check input and AC output for thousands of problems on uDebug!

acar_go
New poster
Posts: 8
Joined: Tue Mar 11, 2014 7:33 pm

Re: 231 - Testing the CATCHER

Post by acar_go » Thu Aug 28, 2014 7:25 pm

Hi guys,

I have WA again and again. I'm going crazy. I need help pls.

Code: Select all

Deleted AC
I tried the test cases for this post and others I have researched.

Thanks :(
Last edited by acar_go on Sat Sep 06, 2014 12:30 pm, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 231 - Testing the CATCHER

Post by brianfry713 » Thu Sep 04, 2014 1:11 am

Your code isn't printing anything
http://ideone.com/fHonaw

Try it without closing the BufferedReader.

The correct sample output is:

Code: Select all

Test #1:
  maximum possible interceptions: 6

Test #2:
  maximum possible interceptions: 2
There is no blank line before the first Test and one blank line between each Test.
Check input and AC output for thousands of problems on uDebug!

acar_go
New poster
Posts: 8
Joined: Tue Mar 11, 2014 7:33 pm

Re: 231 - Testing the CATCHER

Post by acar_go » Fri Sep 05, 2014 2:03 am

brianfry713 wrote:Your code isn't printing anything
http://ideone.com/fHonaw

Try it without closing the BufferedReader.

There is no blank line before the first Test and one blank line between each Test.
Thank you for your attention.

I had to put pr.flush () but i have WA.

I don't know because i have got WA, i tried a tons of testcases and they are correct (uDebug is amazing :D).

Code: Select all

Deleted AC
Last edited by acar_go on Sat Sep 06, 2014 12:29 pm, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 231 - Testing the CATCHER

Post by brianfry713 » Sat Sep 06, 2014 7:11 am

Print a newline char at the end of the last line.
Check input and AC output for thousands of problems on uDebug!

acar_go
New poster
Posts: 8
Joined: Tue Mar 11, 2014 7:33 pm

Re: 231 - Testing the CATCHER

Post by acar_go » Sat Sep 06, 2014 12:29 pm

brianfry713 wrote:Print a newline char at the end of the last line.
Thank you so much! I got AC.

kelvinyee
New poster
Posts: 1
Joined: Sat Jun 06, 2015 7:29 pm

Re: 231 - Testing the CATCHER

Post by kelvinyee » Sat Jun 06, 2015 7:31 pm

Can anyone give me a helping hand?
i keep wrong answer on this question,
but i have correct answer against the sample.

here is my code
thank you

also apologize for my bad English and my messy code

-----------------------------------------------------

problem solved , thank you

Post Reply

Return to “Volume 2 (200-299)”