NK05MNIM - Bốc sỏi

Tác giả: happyboy99x

Ngôn ngữ: C++

#include<bits/stdc++.h>
using namespace std;

int main() {
	int t; cin >> t;
	while(t--) {
		int res = 0, n, mx = 0; cin >> n;
		for(int i = 0, x; i < n; ++i) cin >> x, res ^= x, mx = max(mx, x);
		cout << ((mx <= 1) != (res == 0) ? -1 : 1) << endl;
	}
    return 0;
}

Download