ZJU 3757 模拟坑题


题意:打台球,给定规则,犯规对方的分,否则自己得分。


规则:就一个字烦,至今还有点乱啊~~

  • Cue ball do not hit any object ball. Penalty: the number of target ball.
  • Cue ball is not pocketed and hit at least one ball, but do not hit target ball first or hit more than one object ball first at the same time. Penalty: the largest number of ball in the first hit balls.
  • Cue ball is pocketed and hit at least one ball. Penalty: the largest number of ball in the first hit balls.
       注意还有一条: if the player pockets the target ball with a foul or pockets at least one object ball not including the target ball, this point will be added to the opposite's points.



#include<cstdio>
#include<stdlib.h>
#include<string.h>
#include<string>
//#include<map>
#include<cmath>
#include<iostream>
#include <queue>
#include <stack>
#include<algorithm>
#include<set>
using namespace std;
#define inf 1e8
#define INF -0x3f3f3f3f
#define eps 1e-8
#define ll long long
#define N 1010
#define mol 100007
int main()
{
	int num[1010],n,m,i,j,a,b,p,q;
	int Vis[N*10];
	while(~scanf("%d%d",&n,&m))
	{
		memset(Vis,0,sizeof(Vis));
		for(i=0;i<n;i++)
			scanf("%d",&num[i]);
		sort(num,num+n);
		int flag=0,vis=0,ap=0,bp=0,cnt;
		bool bob=false,ali=true;
		int maxp,maxq,k,sum;
		for(i=0;i<m;i++)
		{
			vis=0;flag=0;maxp=0;maxq=0;cnt=0;
		    sum=0;
			for(j=0;j<n;j++)
				if(Vis[num[j]]==0) break;
			cin>>p;
			int v=p;
			while(v--)
			{
				cin>>a;
				if(a==num[j]&&p==1)
					flag=1;
				if(a>maxp) maxp=a;
			}
			cin>>q;
			int u=q;
			while(u--)
			{
				cin>>b;
				sum+=b;
				Vis[b]=1;
				if(b==num[j])
					vis=1;
				if(b==0) cnt=1;
			}
			if(p==0)
			{
				if(ali)
					bp+=num[j];
				else ap+=num[j];
				ali=!ali;
				bob=!bob;
			}
			else
			{
				if(cnt==0&&flag==0||cnt)
				{
					if(ali)
						bp+=(maxp+sum);
					else ap+=(maxp+sum);
					ali=!ali;
					bob=!bob;
				}
				else if(!vis)
				{
					if(ali) bp+=sum;
					else ap+=sum;
					ali=!ali;
					bob=!bob;
				}
				else 
				{
					if(ali) ap+=sum;
					else bp+=sum;
				}
			}
		}
		printf("%d : %d\n",ap,bp);
	}
	return 0;
}
/*
3 3
2 3 5
2 2 3
1 3
1 2
1 2
1 3
1 0
*/


你可能感兴趣的:(ZJU 3757 模拟坑题)