Codeforces Round 862 (Div. 2) - A. We Need the Zero (800) June 15, 2023 A. We Need the Zero 짝수라면 xxx 가 결국 짝수번 ⊕\oplus⊕되기 때문에 b1⊕b2⊕⋯b_1 \oplus b_2 \oplus \cdotsb1⊕b2⊕⋯가 000이 아니면 불가능하다. 그렇지 않다면 저 결과값을 xxx로 삼아서 출력하면 된다. 펼치기 void solve() { int n; cin >> n; vi a(n); fv(a); int x = 0; for (int i: a) x ^= i; if (n % 2 == 0) { if (x == 0) cout << 0 << endl; else cout << -1 << endl; } else { cout << x << endl; } } Comments
Comments