BOJ 262 Channel Coding
Description
Assume an integer sequence contains N elements whose value could only be one of {0, 1, -1}. There may exist a positive integer D which can make the sum between i-th element
and (i+D)-th element be zero, where i is a certain integer between 1 and N-D. Your task is to find out the maximal D.
Input
First line contains a integer T indicate the number of cases. (T<=50)
In each test case, the first line is N descript above. (N<=50000)
Then follows N integers the sequence contains.
Output
Each case output one integer D in a line. If there is no such a D, just output -1.
Sample Input
2
3
1 0 -1
1
1
Sample Output
2
-1
很简单的hash