QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#184140 | #6789. Yet Another Game of Stones | ucup-team004# | AC ✓ | 60ms | 3936kb | C++20 | 1.4kb | 2023-09-20 13:45:03 | 2023-09-20 13:45:03 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
void solve() {
int n;
std::cin >> n;
std::vector<int> a(n), b(n);
int xorsum = 0;
for (int i = 0; i < n; i++) {
std::cin >> a[i];
xorsum ^= a[i];
}
int cnt[3] {};
for (int i = 0; i < n; i++) {
std::cin >> b[i];
if (a[i] == 1 && b[i] == 1) {
b[i] = 0;
}
cnt[b[i]]++;
}
if (xorsum == 0 || cnt[1] + cnt[2] > 1 || (cnt[1] > 0 && xorsum % 2 == 0)) {
std::cout << "Bob\n";
return;
}
for (int i = 0; i < n; i++) {
if (a[i] % 2 == 1 && b[i] == 2) {
std::cout << "Bob\n";
return;
}
}
if (cnt[1] == 0 && cnt[2] == 0) {
std::cout << "Alice\n";
return;
}
for (int i = 0; i < n; i++) {
if (b[i] == 1) {
if ((xorsum ^ a[i] ^ ((a[i] + 1) % 2)) == 0) {
std::cout << "Alice\n";
return;
}
}
if (b[i] == 2) {
if ((xorsum ^ a[i]) == 0) {
std::cout << "Alice\n";
return;
}
}
}
std::cout << "Bob\n";
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
std::cin >> t;
while (t--) {
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
3 2 4 1 1 0 1 3 2 1 1 2
output:
Alice Bob Bob
result:
ok 3 tokens
Test #2:
score: 0
Accepted
time: 60ms
memory: 3936kb
input:
1015 7 2 3 4 1 5 1 4 0 0 0 0 0 1 2 6 6 5 5 6 5 1 0 1 2 2 2 1 4 2 6 2 3 0 0 0 0 3 4 5 5 0 2 2 6 6 1 6 1 4 5 2 1 1 0 2 0 3 4 4 3 0 1 2 5 6 3 5 4 4 1 2 0 1 1 5 6 3 1 1 5 1 2 1 1 2 4 3 4 5 3 0 0 0 2 4 6 1 5 1 2 1 2 2 5 1 4 3 2 6 1 2 0 0 2 4 6 2 1 1 0 0 2 2 1 6 2 3 5 1 4 2 0 0 1 5 0 6 1 6 6 4 5 6 1 2 1 0...
output:
Alice Bob Alice Bob Bob Bob Bob Bob Bob Bob Bob Bob Alice Bob Alice Bob Bob Bob Bob Alice Bob Alice Bob Alice Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Alice Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Alice Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Alice Alice Al...
result:
ok 1015 tokens