F 题 Hack 数据

8 5 0
4 4 4 1 2 3 5 6
1 2 3 5 6
stdout : Alice

错误的ac代码 :

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

int n, m, k;
int const N = 1e6+10;
int son[N*20][2], idx;
int a[N], b[N];

void insert(int x){
    int p=0;
    for(int i=20; i>=0; i--){
        int u=(x>>i&1);
        if(!son[p][u]) son[p][u]=++idx;
        p=son[p][u];
    }
}

int query(int x){
    int p=0;
    for(int i=20; i>=0; i--){
        int u=(x>>i&1);
        if(!son[p][u]) return 0;
        p=son[p][u];
    }
    return 1;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin>>n>>m>>k;
    for(int i=1; i<=n; i++) cin>>a[i];
    for(int i=1; i<=m; i++) cin>>b[i];
    for(int i=1; i<=m; i++) insert(b[i]);
    
    int s=0;
    for(int i=1; i<=n; i++){
        if(!query(k^a[i])){
            s++;
        }
    }
    
    if(n==1||m==1||s>=n-1||s>=m-1) cout<<"Alice\n";
    else cout<<"Bob\n";
    
	return 0;
} 
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-03 18:13
点赞 评论 收藏
分享
不要停下啊:大二打开牛客,你有机会开卷了,卷起来,去找课程学习,在牛客上看看大家面试笔试都需要会什么,岗位有什么需求就去学什么,努力的人就一定会有收获,这句话从来都经得起考验,像我现在大三了啥也不会,被迫强行考研,炼狱难度开局,啥也不会,找工作没希望了,考研有丝丝机会
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务