QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#420929#6789. Yet Another Game of StonesYanagi_OrigamiAC ✓60ms4388kbC++141.7kb2024-05-25 03:54:452024-05-25 03:54:45

Judging History

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

  • [2024-05-25 03:54:45]
  • 评测
  • 测评结果:AC
  • 用时:60ms
  • 内存:4388kb
  • [2024-05-25 03:54:45]
  • 提交

answer

// left side, row 3 (0-indexed), inner desk, University of Washington
// (we need scratch paper)
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define forn(i, a, b) for (int i = (a); i < (b); i++)
#define fore(i, a, b) for (int i = (a); i <= (b); i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)((x).size())
using ll = long long;
using ii = pair<int, int>;

void solve() {
    int n;
    cin >> n;
    int arr[n], brr[n];
    for (int i = 0; i < n; ++i) cin >> arr[i];
    for (int i = 0; i < n; ++i) cin >> brr[i];
    int  cnt[3]={0};
    int c0 = 0, pos =-1;
    bool used = false;
    for (int i = 0; i < n; ++i) {
        if (brr[i] == 0 || (brr[i] == 1 && arr[i] == 1)) {
            c0 ^= arr[i];
        }
        if (brr[i] == 2 && arr[i] % 2 == 1) {
            cout << "Bob" << endl;
            return;
        }
        if(arr[i]!=1) cnt[brr[i]] ++;
        if(brr[i]!=0&&arr[i]!=1) pos = i;
    }
    if(cnt[1]+cnt[2]>=2){
        cout<<"Bob"<<endl;
        return ;
    }
    if(c0 == 1 && cnt[1]==1 && cnt[2] == 0 && arr[pos]%2==0){
        cout<<"Alice"<<endl;
        return ;
    }

    if(c0 == 0 && cnt[1]==1 && cnt[2] == 0 && arr[pos]%2==0){
        cout<<"Bob"<<endl;
        return ;
    }

    if((c0 == 0 && (cnt[1]+cnt[2]==1)) || (c0 != 0 && (cnt[1]+cnt[2] == 0))){
        cout<<"Alice"<<endl;
    }else{
        cout<<"Bob"<<endl;
    }
    // if ((c0 == 0 && !used) || (c0 != 0 && used)) {
    //     cout << "Alice" << endl;
    // } else {
    //     cout << "Bob" << endl;
    // }
}

int main()
{
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);

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


}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 4388kb

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