Created
April 2, 2023 18:00
-
-
Save qjatn0120/75280eb32eeee57430e26c485cc75f96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DEBUG | |
#include "debug.h" | |
#endif // DEBUG | |
#ifndef DEBUG | |
template <typename T> | |
void debug(T &x){} | |
#endif // DEBUG | |
#include <bits/stdc++.h> | |
using namespace std; | |
int main(){ | |
cin.tie(nullptr), ios::sync_with_stdio(false); | |
int t; | |
cin >> t; | |
while(t--){ | |
int n; | |
cin >> n; | |
int res = 0; | |
for(int i = 0; i < n; i++){ | |
int a; | |
cin >> a; | |
res ^= a; | |
} | |
if(n & 1) cout << res << '\n'; | |
else{ | |
if(res) res = -1; | |
cout <<res << "\n"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment