EnKrypt

Vertical Rooks - Hackerrank [most compact/fast]

Oct 24th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. import java.io.*;
  2. public class Solution {
  3.     public static void main(String[] args)throws IOException {
  4.         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  5.         int T=Integer.parseInt(br.readLine());
  6.         for (int i=0;i<T;i++){
  7.             int N=Integer.parseInt(br.readLine());
  8.             int[] a=new int[N],b=new int[N];
  9.             for (int j=0;j<N;j++){
  10.                 a[j]=Integer.parseInt(br.readLine());
  11.             }
  12.             for (int j=0;j<N;j++){
  13.                 b[j]=Integer.parseInt(br.readLine());
  14.             }
  15.             int sum=0;
  16.             for (int h=0;h<a.length;h++)
  17.                 sum=sum^(Math.abs(a[h]-b[h])-1);
  18.             if (sum!=0)
  19.                 System.out.println("player-2");
  20.             else
  21.                 System.out.println("player-1");
  22.         }
  23.     }
  24. }
Add Comment
Please, Sign In to add comment