QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#364811#6789. Yet Another Game of StonesXiangmyWA 57ms3960kbC++201.7kb2024-03-24 16:47:362024-03-24 16:47:36

Judging History

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

  • [2024-03-24 16:47:36]
  • 评测
  • 测评结果:WA
  • 用时:57ms
  • 内存:3960kb
  • [2024-03-24 16:47:36]
  • 提交

answer

/*
* Author: Xiangmy
* Created: 2024-03-24 16:02
* Problem: 
* Description: 博弈 nim游戏
* 如果除A的 1、2 限制外就是普通的nim游戏。于是只剩下4种情况需要特判。
* 1.奇数(1):如果大于1,A先手不取完,B就取完,A输;否则B变为先手。
* 2.奇数(2):A必输
* 3.偶数(1):需要A先手将其取至1,进行nim游戏。
* 4.偶数(2):A先手不取完,B就取完,A输;否则B变为先手。
* 2 || (1 && 4) 则必输
*/
// #pragma GCC optimize(2)
// #pragma GCC optimize(3, "Ofast", "inline")
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << ": " << (x) << ' '
// #define x first
// #define y second
typedef long long LL;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> PII;

void solve() {
    int n; cin >> n;
    vector<int> a(n + 1), b(n + 1);
    for (int i = 1; i <= n; ++ i) cin >> a[i];
    for (int i = 1; i <= n; ++ i) cin >> b[i];

    int ans = 0;
    int cnt = 0;
    bool lose = false;
    for (int i = 1; i <= n; ++ i) {
        if (a[i] == 1 && b[i] == 1) ans ^= 1;
        else if ((a[i] & 1) == (b[i] & 1)) cnt ++;
        else if ((a[i] & 1) && b[i] == 2) lose = true;
        else ans ^= a[i];
    }

    if (lose || cnt > 1) cout << "Bob\n";
    else if (cnt && ans || !cnt && !ans) cout << "Bob\n";
    else cout << "Alice\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);  // 交互题不用
    cout.tie(0);
    // cout << fixed << setprecision(6);
    // cout << setw(4) << setfill('0');
    // init();
    int T = 1;
    cin >> T;
    while (T -- ) {
        // cin.ignore(numeric_limits<std::streamsize>::max(), '\n');
        solve();
    }
    return 0;
}

详细

Test #1:

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

input:

3
2
4 1
1 0
1
3
2
1
1
2

output:

Alice
Bob
Bob

result:

ok 3 tokens

Test #2:

score: -100
Wrong Answer
time: 57ms
memory: 3960kb

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:

Bob
Bob
Bob
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
Alice
Bob
Bob
Alice
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Alice
Bob
Alice
Alice
Bo...

result:

wrong answer 1st words differ - expected: 'Alice', found: 'Bob'