My code solves the samples perfectly and i also believe its true for all cases 
but still i got a WA in my submission, can anyone see an issue with this code?

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Solution {

        public static void main(String[] args) {
                Scanner scanner = new Scanner(new BufferedReader(new 
InputStreamReader(
                                System.in)));
                int testCasesNum = scanner.nextInt();
                for (int i = 1; i <= testCasesNum; i++) {
                        int p = scanner.nextInt();
                        int q = scanner.nextInt();
                        Integer[][] sortedArrayX = new Integer[p*2][];
                        Integer[][] sortedArrayY = new Integer[p*2][];
                        for (int j = 0; j < p; j++){
                                int xj = scanner.nextInt();
                                int yj = scanner.nextInt();
                                char dj = scanner.next().trim().charAt(0);
                                switch (dj){
                                        case 'N':
                                                sortedArrayX[j*2] = new 
Integer[] {0, 0};
                                                sortedArrayX[j*2 + 1] = new 
Integer[] {q , 1};
                                                sortedArrayY[j*2] = new 
Integer[] {yj + 1, 0};
                                                sortedArrayY[j*2 + 1] = new 
Integer[] {q , 1};
                                        break;
                                        case 'S':
                                                sortedArrayX[j*2] = new 
Integer[] {0, 0};
                                                sortedArrayX[j*2 + 1] = new 
Integer[] {q , 1};
                                                sortedArrayY[j*2] = new 
Integer[] {0, 0};
                                                sortedArrayY[j*2 + 1] = new 
Integer[] {yj - 1 , 1};
                                        break;
                                        case 'E':
                                                sortedArrayX[j*2] = new 
Integer[] {xj + 1, 0};
                                                sortedArrayX[j*2 + 1] = new 
Integer[] {q , 1};
                                                sortedArrayY[j*2] = new 
Integer[] {0, 0};
                                                sortedArrayY[j*2 + 1] = new 
Integer[] {q , 1};
                                        break;
                                        case 'W':
                                                sortedArrayX[j*2] = new 
Integer[] {0, 0};
                                                sortedArrayX[j*2 + 1] = new 
Integer[] {xj - 1 , 1};
                                                sortedArrayY[j*2] = new 
Integer[] {0, 0};
                                                sortedArrayY[j*2 + 1] = new 
Integer[] {q , 1};
                                        break;
                                }
                        }
                        Arrays.sort(sortedArrayX, new Comparator<Integer[]>() {

                                @Override
                                public int compare(Integer[] o1, Integer[] o2) {
                                        int res = o1[0] - o2[0];
                                        if (res == 0)
                                                res = o1[1] - o2[1];
                                        return res;
                                }
                        });
                        Arrays.sort(sortedArrayY, new Comparator<Integer[]>() {

                                @Override
                                public int compare(Integer[] o1, Integer[] o2) {
                                        int res =  o1[0] - o2[0];
                                        if (res == 0)
                                                res = o1[1] - o2[1];
                                        return res;
                                }
                        });
                        
                        int maxIntersectionsX = 0;
                        int xStart = 0, xEnd;
                        int currentIntersectionsX = 0;
                        for (int j = 0; j < p; j++){
                                if (sortedArrayX[j][1] == 0){
                                        currentIntersectionsX++;
                                        if (currentIntersectionsX > 
maxIntersectionsX){
                                                xStart = sortedArrayX[j][0];
                                                maxIntersectionsX = 
currentIntersectionsX;
                                        }
                                }
                                if (sortedArrayX[j][1] == 1){
                                        if (currentIntersectionsX == 
maxIntersectionsX){
                                                xEnd = sortedArrayX[j][0];
                                        }
                                        currentIntersectionsX--;
                                }
                        }
                        
                        int maxIntersectionsY = 0;
                        int yStart = 0, yEnd;
                        int currentIntersectionsY = 0;
                        for (int j = 0; j < p; j++){
                                if (sortedArrayY[j][1] == 0){
                                        currentIntersectionsY++;
                                        if (currentIntersectionsY > 
maxIntersectionsY){
                                                yStart = sortedArrayY[j][0];
                                                maxIntersectionsY = 
currentIntersectionsY;
                                        }
                                }
                                if (sortedArrayY[j][1] == 1){
                                        if (currentIntersectionsY == 
maxIntersectionsY){
                                                yEnd = sortedArrayY[j][0];
                                        }
                                        currentIntersectionsY--;
                                }
                        }
                        
                        System.out.println("Case #" + i + ": " + xStart + " " + 
yStart);
                }
                try{
                        scanner.close();
                }
                catch (Exception e){}
                System.out.flush();
        }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/2bbec04b-916d-452f-a165-b7f522196d5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to