fork download
  1. //Coded by Vishal Mourya
  2. //If you use this code anywhere you need to mention my name as above
  3.  
  4. /* package whatever; // don't place package name! */
  5.  
  6. import java.util.*;
  7. import java.lang.*;
  8. import java.io.*;
  9.  
  10. /* Name of the class has to be "Main" only if the class is public. */
  11.  
  12. //Note : If you are running this code on codechef then replace Ideone with Codechef
  13. class Ideone //Codechef
  14. {
  15. public static void main (String[] args) throws java.lang.Exception
  16. {
  17. try{
  18.  
  19. //write your code here
  20. Scanner sc = new Scanner(System.in);
  21. int t = sc.nextInt();
  22.  
  23. while(t > 0){
  24. int n = sc.nextInt();
  25.  
  26. int[] v = new int[n];
  27.  
  28. for( int i = 0 ; i < v.length ; i++ ){
  29. v[i] = sc.nextInt();
  30. }
  31.  
  32. //main logic of problem
  33. int allXor = v[0] ^ v[1];
  34.  
  35. for( int i = 2 ; i < v.length ; i++) {
  36. allXor ^= ( v[i] );
  37. }
  38.  
  39. if( allXor % 2 == 0 ){
  40. System.out.println("YES");
  41. }
  42. else{
  43. System.out.println("NO");
  44. }
  45. t -= 1;
  46. }//end of test case loop
  47.  
  48. }//end of catch block
  49.  
  50. catch(Exception e){
  51. //your Exeception here
  52. }
  53. }
  54. }
Success #stdin #stdout 0.1s 35020KB
stdin
2
4
1 2 3 4
2
100 111
stdout
YES
NO