QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#420931#6789. Yet Another Game of StonesSteAC ✓61ms4428kbC++141.5kb2024-05-25 04:11:252024-05-25 04:11:25

Judging History

你现在查看的是最新测评结果

  • [2024-05-25 04:11:25]
  • 评测
  • 测评结果:AC
  • 用时:61ms
  • 内存:4428kb
  • [2024-05-25 04:11:25]
  • 提交

answer

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

void solve() {
    int n;
    cin >> n;
    int a[n];
    int b[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int one_cnt = 0;
    int two_cnt = 0;
    bool all_even = true;
    bool odd = true;
    int xor_0 = 0;
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        if (b[i] == 1 && a[i] == 1) {
            b[i] = 0;
        }

        if (b[i] == 2) {
            two_cnt++;
            if (a[i] % 2 != 0) {
                all_even = false;
            }
        } else if (b[i] == 1) {
            if (a[i] % 2 == 0) {
                odd = false;
            }
            one_cnt++;
        } else {
            xor_0 ^= a[i];
        }
    }

    if (two_cnt >= 2 || (two_cnt == 1 && !all_even)) {
        cout << "Bob\n";
    } else if (two_cnt == 1) {
        if (one_cnt >= 1) {
            cout << "Bob\n";
        } else {
            cout << (xor_0 != 0 ? "Bob" : "Alice") << "\n";    
        }
    } else if (one_cnt == 0) {
        cout << (xor_0 == 0 ? "Bob" : "Alice") << "\n";
    } else if (one_cnt >= 2) {
        cout << "Bob\n";
    } else {
        if (odd) {
            cout << (xor_0 != 0 ? "Bob" : "Alice") << "\n";    
        } else {
            cout << ((xor_0 ^ 1) != 0 ? "Bob" : "Alice") << "\n";
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3624kb

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: 61ms
memory: 4428kb

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