版本比较
题解:P14787 [NERC 2025] Fragmented Nim
正文
增加 5 行删除 5 行
65 行未改动6667686970707172737475767677787980808182838485868687888990919293949595969798994 行未改动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 { // 存在至少一堆石子数大于1 cout << (xor_sum != 0 ? "Alice" : "Bob") << '\n'; } }
return 0;}```
4 行未改动