Page 4 of 4

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

Posted: Fri Mar 29, 2013 2:07 am
by sun_kuet
after accepted i i removed the code

Re: WA 231 Testing the catcher

Posted: Wed May 14, 2014 11:53 pm
by riger400
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();
}
}

Re: WA 231 Testing the catcher

Posted: Thu May 15, 2014 8:29 pm
by brianfry713
There should be two spaces before maximum.

Re: 231 - Testing the CATCHER

Posted: Thu Aug 28, 2014 7:25 pm
by acar_go
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 :(

Re: 231 - Testing the CATCHER

Posted: Thu Sep 04, 2014 1:11 am
by brianfry713
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.

Re: 231 - Testing the CATCHER

Posted: Fri Sep 05, 2014 2:03 am
by acar_go
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

Re: 231 - Testing the CATCHER

Posted: Sat Sep 06, 2014 7:11 am
by brianfry713
Print a newline char at the end of the last line.

Re: 231 - Testing the CATCHER

Posted: Sat Sep 06, 2014 12:29 pm
by acar_go
brianfry713 wrote:Print a newline char at the end of the last line.
Thank you so much! I got AC.

Re: 231 - Testing the CATCHER

Posted: Sat Jun 06, 2015 7:31 pm
by kelvinyee
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