Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

codechefxorquestionsept17

import java.util.Scanner;
class Main{
 
     public static void main(String []args){
Scanner in= new Scanner(System.in);
int N=in.nextInt();
int test=in.nextInt();
int c,d,day=0;
int[][] nodes= new int[N][2];
for(int i=0; i<N-1; i++)
{c=in.nextInt();
d=in.nextInt();
    nodes[d][1]=c;
}
for(int j=0; j<N; j++)
{nodes[j][0]=in.nextInt();}
     int days[]= new int[test];
         for(int k=0; k<test; k++)
         {days[k]=in.nextInt();
             
         }
         for(int y=0; y<test; y++)
    	 {for(; day<days[y]; day++)
    	 {
     {for(int k=N-1; k>=0; k--)
     {for(int l=N-1; l>k; l--)
     {if (nodes[l][1]==k)
     {nodes[k][0]=nodes[k][0]^nodes[l][0];
    	 }}
     }}
        
    	 
     }System.out.println(nodes[0][0]);
     }in.close();
}}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.