F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Stabilization

Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 592    Accepted Submission(s): 243


Problem Description
The instability of a array A with length N is defined as $\sum_{i=1}^{N-1}(|A[i+1]-A[i]|)$. In order to stabilize a array, changing every element A[i] to (A[i] xor X) is allowed. What is the smallest non-negative integer X to minimize the instability of a given array?

 

Input
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases.
For each test case, the first line contains an integer N. Next line contains N integers, indicating the elements of the array.
T<=10, 0<=A[i]<2^20, 1<=n<=10^5.
 

Output
For each test case, output two integers in one line, the smallest non-negative integer X and the minimum of the instability.
 

Sample Input
2 3 0 3 0 3 1 3 1
 

Sample Output
1 2 0 4
 

Author
UESTC
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-19 00:37:03, Gzip enabled