XOR Segment
Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 41 Accepted Submission(s) : 14
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
给出 n 个数的数列,让你求出异或和为零的连续子段,如果有多个答案,要求连续字段长度最短,如果长度最短子段有多个,取最靠前的字段。
异或操作体现在C++里面:^操作,两数做异或的含义是其对应的每一位二进制位做异或,例如:5 ^ 7 = (101) ^ (111) = (010) = 2
异或操作体现在C++里面:^操作,两数做异或的含义是其对应的每一位二进制位做异或,例如:5 ^ 7 = (101) ^ (111) = (010) = 2
Input
第一行一个数据组数 T,(T <= 100)
每组数据第一行一个 n(n <= 10^6)
第二行给出 n 个数,0 <= 数值 < 10^5
每组数据第一行一个 n(n <= 10^6)
第二行给出 n 个数,0 <= 数值 < 10^5
Output
每组数据输出一行子段的左右端点,如果不存在这样的字段,输出-1
Sample Input
3 5 1 2 3 4 5 2 2 4 3 4 0 4
Sample Output
1 3 -1 2 2