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;
}
查看2道真题和解析
