Chefina and Swaps SOLUTIONS CHEFPART

Chefina and Swaps SOLUTIONS CHEFPART

Chefina calls a succession decent if its absolutely impossible to separate it into two non-void bordering aftereffects (not really with equivalent length) to such an extent that the bitwise OR of the components of one aftereffect is equivalent to the bitwise OR of the components of the other aftereffect. 
 
You are given an arrangement of positive whole numbers A1,A2,… ,AN. Chefina solicited Chef to reorder the components from this grouping (potentially leaving it unaltered) so that the subsequent arrangement would be acceptable ― in the event that it is conceivable. Notwithstanding, that was a simple assignment for Chef, so at whatever point it is conceivable to make the given arrangement great, Chefina requested that he do it by trading nearby combines of its components and to utilize the littlest conceivable number of trades. 
 
Locate the most modest number of trades Chef needs to act so as to make the given arrangement great or verify that its absolutely impossible to make it great. 
 
Info 
 
The main line of the information contains a solitary whole number T meaning the quantity of experiments. The portrayal of T experiments follows. 
 
The primary line of each experiment contains a solitary number N. 
 
The subsequent line contains N space-isolated numbers A1,A2,… ,AN. 
 
Yield 
 
For each experiment, print a solitary line containing one number ― the most modest number of trades Chef needs to make the grouping great or −1 in the event that it is outlandish. 
 
Limitations 
 
1≤T≤1,000 
 
1≤N≤105 
 
1≤Ai≤106 for each legitimate I 
 
the total of N over all experiments doesn’t surpass 5⋅105 
 
Subtasks 
 
Subtask #1 (50 focuses): 
 
N≤1,000 
 
the total of N over all experiments doesn’t surpass 5,000 
 
Subtask #2 (50 focuses): unique limitations 
 
Model Input 
 
 
 
3 6 7 
 
 
 
 
2 3 9 13 14 6 13 
 
Model Output 
 
 
– 1 
 
5
 

March Long Challenge 2021 Solutions

April Long Challenge 2021 Solutions

Codechef Long Challenge Solutions

February Long Challenge 2021

1. Frog Sort Solution Codechef

2. Chef and Meetings Solution Codechef

3. Maximise Function Solution Codechef

4. Highest Divisor Solution Codechef

5. Cut the Cake Challenge Solution Codechef

6. Dream and the Multiverse Solution Codechef

7. Cell Shell Solution Codechef

8. Multiple Games Solution Codechef

9. Another Tree with Number Theory Solution Codechef

10. XOR Sums Solution Codechef

11. Prime Game Solution CodeChef

12. Team Name Solution Codechef

January Long Challenge 2021

November Challenge 2020 SOLUTION CodeChef

October Lunchtime 2020 CodeChef SOLUTIONS

RELATED :

Related :

Related :

Leave a Comment