3757一个模拟题,简单,但容易错;
3758 大素数判定就行;
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 100009
using namespace std; int ans[];
int hit[maxn];
int in[maxn];
int ball[maxn];
bool vis[maxn]; int main()
{
int n,m;
int p,q;
while(scanf("%d%d",&n,&m)!=EOF)
{
ans[]=;
ans[]=;
memset(vis,,sizeof vis);
for(int i=; i<n; i++)
scanf("%d",&ball[i]);
sort(ball,ball+n);
int ma1=-;
int sumofin=;
int tar=;
int turn=;
for(int i=; i<m; i++)
{
bool flag1=,flag2=,flag3=;
for(tar; tar<n; tar++)
if(vis[ball[tar]]==)
break;
ma1=;
sumofin=;
scanf("%d",&p);
for(int i=; i<p; i++)
{
scanf("%d",&hit[i]);
if(hit[i]>ma1)ma1=hit[i];
if(hit[i]==ball[tar]&&p==) flag1=;//只击中目标球;
}
scanf("%d",&q);
for(int i=; i<q; i++)
{
scanf("%d",&in[i]);
sumofin+=in[i];
vis[in[i]]=;
if(in[i]==ball[tar])flag2=;//目标球进了;
if(in[i]==)flag3=;//白球进了;
}
if(p==)
{
turn=-turn;
ans[turn]+=ball[tar];
}
else
{
if(flag3==&&flag1==)
{
turn=-turn;
ans[turn]+=ma1;
ans[turn]+=sumofin;
}
else if(flag3&&p)
{
turn=-turn;
ans[turn]+=ma1;
ans[turn]+=sumofin;
}
else if(flag2==)
{
turn=-turn;
ans[turn]+=sumofin;
}
else
{
ans[turn]+=sumofin;
}
}
}
printf("%d : %d\n",ans[],ans[]);
}
return ;
}