231 - Testing the CATCHER
Moderator: Board moderators
WA :( plz help.... 231- Testing the CATCHER
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.
Re: WA 231 Testing the catcher
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();
}
}
[/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();
}
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: WA 231 Testing the catcher
There should be two spaces before maximum.
Check input and AC output for thousands of problems on uDebug!
Re: 231 - Testing the CATCHER
Hi guys,
I have WA again and again. I'm going crazy. I need help pls.
I tried the test cases for this post and others I have researched.
Thanks![:(](./images/smilies/icon_frown.gif)
I have WA again and again. I'm going crazy. I need help pls.
Code: Select all
Deleted AC
Thanks
![:(](./images/smilies/icon_frown.gif)
Last edited by acar_go on Sat Sep 06, 2014 12:30 pm, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 231 - Testing the CATCHER
Your code isn't printing anything
http://ideone.com/fHonaw
Try it without closing the BufferedReader.
The correct sample output is:There is no blank line before the first Test and one blank line between each Test.
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
Check input and AC output for thousands of problems on uDebug!
Re: 231 - Testing the CATCHER
Thank you for your attention.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.
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](./images/smilies/icon_biggrin.gif)
Code: Select all
Deleted AC
Last edited by acar_go on Sat Sep 06, 2014 12:29 pm, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 231 - Testing the CATCHER
Print a newline char at the end of the last line.
Check input and AC output for thousands of problems on uDebug!
Re: 231 - Testing the CATCHER
Thank you so much! I got AC.brianfry713 wrote:Print a newline char at the end of the last line.
Re: 231 - Testing the CATCHER
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
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