F题数据太弱

Hack数据:

5 4 1

100 100 2 3 4

0 3 2 5

true stdout:Alice

false stdout:Bob

要Bob对于Alice手中能够接的上的牌保留一张,其余的牌全部和接不起的牌对出。之前没考虑这种情况直接交了,但是过了,可能是牛客官方出题数据过小。。。

HACK代码:

#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define PII pair<int,int>
#define endl "\n"
const int N=1e7+10;
const int INF=1e18;
const int mod=998244353;
int a[N],b[N];
int n,m,k;
void solve()
{
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        a[x]++;
    }
    for(int i=1;i<=m;i++)
    {
        int x;
        cin>>x;
        b[x^k]++;
    }
    int sum=0;
    for(int i=0;i<N;i++)
    {
        if(!b[i])
        {
            sum+=a[i];
        }
    }
    if(sum+1>=min(n,m))cout<<"Alice"<<endl;
    else cout<<"Bob"<<endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T=1;
//     cin>>T;
    while(T--)solve();
    return 0;
}

补一下正确代码:

#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define PII pair<int,int>
#define endl "\n"
const int N=1e7+10;
const int INF=1e18;
const int mod=998244353;
int a[N],b[N];
int n,m,k;
void solve()
{
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        a[x]++;
    }
    for(int i=1;i<=m;i++)
    {
        int x;
        cin>>x;
        b[x^k]++;
    }
    int sum=0;
    int chu=0;
    for(int i=0;i<N;i++)
    {
        if(a[i]==0&&b[i])sum+=b[i];
        else if(a[i]&&b[i])sum+=(b[i]-1);
        else if(a[i]&&b[i]==0)chu+=a[i];
    }
    if(chu+1>=min(n,m))cout<<"Alice"<<endl;
    else 
    {
        if(chu>sum)cout<<"Alice"<<endl;
        else cout<<"Bob"<<endl;
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T=1;
//     cin>>T;
    while(T--)solve();
    return 0;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-07 13:47
机械打工仔:你自己匿名可以,这么好的公司就别给它匿名了
点赞 评论 收藏
分享
06-23 11:43
门头沟学院 Java
allin校招的烤冷...:我靠,今天中午我也是这个hr隔一个星期发消息给我。问的问题还是一模一样的😅
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-09 12:02
ssob上原来真有BOSS啊
硫蛋蛋:这种也是打工的,只不是是给写字楼房东打工
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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