QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#575847#6789. Yet Another Game of StonesZhi_zIAC ✓62ms5272kbC++172.5kb2024-09-19 17:00:332024-09-19 17:00:34

Judging History

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

  • [2024-09-19 17:00:34]
  • 评测
  • 测评结果:AC
  • 用时:62ms
  • 内存:5272kb
  • [2024-09-19 17:00:33]
  • 提交

answer

#include <bits/stdc++.h>

/* Orther */
#define int long long
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define IOS ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
using namespace std;

/* Pair */
#define x first
#define y second

/* Data type */
using ll = long long;
using ull = unsigned long long;
using PII = pair<int,int>;
using VI = vector<int>;

/* STL */
#define eb emplace_back
#define ef emplace_front
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define all1(x) x.begin()+1,x.end()

/* Random */
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define random(a,b) rng()%(b-a+1)+a

/* Contest */
const int INF = 0x3f3f3f3f ; // 1e9
const int MOD =  998244353 ;
const int N = 100005, M = 55;

#define Bob cout<<"Bob\n"
#define Alice cout<<"Alice\n"
int a[N] , b[N] ;

void Rainbow_()
{
    int n ; cin >> n;
    for (int i = 1; i <= n; i ++ ) {
    	cin >> a[i];
    }
    for (int i = 1; i <= n; i ++ ) {
    	cin >> b[i];
    }
    
    bool ok = false ;
    int cnt1 = 0 , cnt2 = 0;

    for (int i = 1; i <= n ; i ++ ) {
    	if (a[i] % 2 && b[i] == 2) {
    // Alice 拿不了 这个 1
    		ok = true;
    	}
    // Alice 会在这里用一次(交换先后手)
    	if ( a[i] > 1 && b[i] == 1 ) {
    		cnt1 ++ ;
    	}
    // Alice 必定交换先后手 , 否则必输
    	if ( a[i] % 2 == 0 && b[i] == 2 ) {
    		cnt2 ++ ;
    	}
    }
    
    // 特殊点大于 1
    if (cnt1 + cnt2 > 1 || ok) {
    	Bob ;
    } else if (cnt1 == 0 && cnt2 == 0) { // 没有限制就是NIM游戏
    	int sum = 0;
    	for (int i = 1; i <= n; i ++ ) {
    		sum ^= a[i];
    	}
    	if (sum == 0) {
    		Bob ;
    	} else {
    		Alice ;
    	}
    } else if ( cnt1 == 0 && cnt2 == 1 ) { 
    	int sum = 0;
    	for (int i = 1; i <= n; i ++ ) {
    		if ( b[i] != 2 ) {
    			sum ^= a[i];
    		}
    	}
    	if (sum == 0) {
    		Alice ;
    	} else {
    		Bob ;
    	} 
    } else if (cnt1 == 1 && cnt2 == 0) {
    	int num = 0;
    	for (int i = 1; i <= n; i ++ ) {
    		if ( b[i] == 1 && a[i] > 1 ) {
    			if ( a[i] % 2 == 0 ) {
    				num ^= 1;
    			}
    		} else {
    			num ^= a[i];
    		}
    	}
    	if ( num == 0 ) {
    		Alice ;
    	} else {
    		Bob ;
    	}
    }
    
    return ;
}
 
signed main()
{   
    IOS;
    int _ = 1;
    cin >> _;
 
    while ( _ -- ) 
        Rainbow_();
 
    return 0;
}

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

详细

Test #1:

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

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: 62ms
memory: 5272kb

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