Question: We have N computers running on a system where each computer has a parent computer that redirects tasks to it and all the computers form
We have N computers running on a system where each computer has a parent computer that redirects tasks to it and all the computers form a tree rooted at computer
Each computer has a latency Ai
The power of a computer is the minimum Bitwise XOR between its latency and the latency of any computer of it's parent.
Each computer has a chance to fail when the the number of tasks exceeds it's power.
You are given Q queries each containing the number of a computer and you have to do the following:
Calculate the maximum number of tasks that can be passed to this computer so it won't fail and all its subtree of computers won't fail.
Find the sum of answers to all queries. Since the answer can be large, return it modulo The first line contains an integer, N denoting the number of elements in latency.
The next line contains an integer, M denoting the number of elements in parents.
Each line i of the M subsequent lines where i M contains an integer describing parentsi
Each line i of the N subsequent lines where i N contains an integer describing latencyi
The next line contains an integer, q denoting the number of elements in queries.
Each line i of the q subsequent lines where i q contains an integer describing queriesi
Constraints
N
M
parentsi
latencyi
q
queriesi
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
