https://codeforces.com/contest/1516/problem/B


Baby Ehab is known for his love for a certain operation. He has an array aa of length nn, and he decided to keep doing the following operation on it:

  • he picks 22 adjacent elements; he then removes them and places a single integer in their place: their bitwise XOR
    #include <bits/stdc++.h>
    typedef long long ll;
    using namespace std;
    int main()
    {
        ios_base::sync_with_stdio(false);
        int t;
        cin>>t;
        while(t--){
            int n;cin>>n;
            int *a=new int[n+1];
            int sum=0;
            for(int i=1;i<=n;i++){
                cin>>a[i];sum^=a[i];
            }
            if(!sum){
                cout<<"YES\n";continue;
            }
            int cnt=0;
            for(int i=1,j;i<=n;i=j+1){
                j=i;
                int now=a[i];
                while(j<n&&now!=sum){
                    j++;
                    now^=a[j];
                }
                if(now==sum)cnt++;
            }
            cout<<(cnt>2?"YES":"NO")<<"\n";
        }
    }
    

      

    . Note that the length of the array decreases by one.

Now he asks you if he can make all elements of the array equal. Since babies like to make your life harder, he requires that you leave at least 22 elements remaining.

Input

The first line contains an integer tt (1t151≤t≤15) — the number of test cases you need to solve.

The first line of each test case contains an integers nn (2n20002≤n≤2000) — the number of elements in the array aa.

The second line contains nn space-separated integers a1a1, a2a2, …, anan (0ai<2300≤ai<230) — the elements of the array aa.

Output

If Baby Ehab can make all elements equal while leaving at least 22 elements standing, print "YES". Otherwise, print "NO".


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM