版本比较
题解:P14787 [NERC 2025] Fragmented Nim
正文
增加 5 行删除 5 行
65 行未改动666768697071727374757677787980818283848586878889909192939495969798994 行未改动65 行未改动int main() {ios::sync_with_stdio(false);cin.tie(nullptr);int t;cin >> t;while (t--) {int n;cin >> n;vector<int> a(n);bool all_one = true;int xor_sum = 0;for (int i = 0; i < n; i++) {cin >> a[i];if (a[i] > 1) all_one = false;xor_sum ^= a[i];}if (all_one) {// 所有堆都只有1颗石子cout << (n % 2 == 1 ? "Bob" : "Alice") << '\n';} else {// 存在至少一堆石子数大于1cout << (xor_sum != 0 ? "Alice" : "Bob") << '\n';}}return 0;}```4 行未改动65 行未改动666768697071727374757677787980818283848586878889909192939495969798994 行未改动65 行未改动int main() {ios::sync_with_stdio(false);cin.tie(nullptr);int t;cin >> t;while (t--) {int n;cin >> n;vector<int> a(n);bool all_one = true;int xor_sum = 0;for (int i = 0; i < n; i++) {cin >> a[i];if (a[i] > 1) all_one = false;xor_sum ^= a[i];}if (all_one) {// 所有堆都只有1颗石子cout << (n % 2 == 1 ? "Bob" : "Alice") << '\n';} else {// 存在至少一堆石子数大于1cout << (xor_sum != 0 ? "Alice" : "Bob") << '\n';}}return 0;}```4 行未改动