HDU4023 Game The 36th ACM/ICPC Asia Regional Shanghai Site —— Online Contest

Game

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 9 Accepted Submission(s): 4


Problem Description
Alice and Bob are playing game with each other. They play the game on a 2D board. Alice has many vertical 1*2 tiles while Bob has many horizontal 2*1 tiles. They take turn to place their own tiles on the board. Considering about that the tiles cannot overlap each other, the player cannot do the placement any more loses. Since this is such a complex game that they could not find optimal method to play that, Alice decide to simplify this game by replace the large 2D board by some small ones. Alice set up a lot of Tetris tiles instead of the original 2D board. In the other words, the player can only place their own vertical or horizontal tiles on the Tetris-like board. Each player can choose one possible place on any Tetris tiles to place its own tiles. In fact, there are following 15 types of Tetris playground.

The playground cannot be transformed in any ways, including reflection and rotation.
Given the number of each type of tiles, you are asked to determine who will win the game if Alice plays first and both players are playing optimal.


Input
There are multiple test cases; the first line of input contains a single integer denoting the number of test cases.
For each test case, there are only one line contains 15 integers denoting the number of Tetris tiles of the above 15 types. All the numbers are no greater than 100.


Output
For each test cases, output “Alice” if Alice will win the game and both player plays optimally, “Bob” otherwise.


Sample Input
3
5 4 0 0 0 0 0 0 0 0 0 0 0 0 0
5 5 0 0 0 0 0 0 0 0 0 0 0 0 0
100 100 0 0 0 0 0 0 0 0 0 2 1 0 0


Sample Output
Case #1: Alice
Case #2: Bob
Case #3: Alice
Source


Recommend
lcy


 

 

两个人分别对每种tiles分配一个优先级,

分别计算A选第i中能覆盖几次,同时B在A选i后能覆盖第i种几次,反之亦是如此。

然后模拟计算两人覆盖的次数,比较谁覆盖次数大。

代码:

#include<cstdio>

int p1[]={15,5,6,3,4,11,12,13,14,7,8,9,10,1};
int c1[]={2,0,1,1,2,2,1,1,1,1,1,1,1,1,2};
int d2[]={0,2,0,0,0,0,0,0,1,1,0,0,0,0,0};
int p2[]={15,3,4,5,6,11,12,13,14,9,10,7,8,2};
int c2[]={0,2,2,2,1,1,1,1,1,1,1,1,1,1,2};
int d1[]={2,0,0,0,0,0,1,1,0,0,0,0,0,0,0};
int t,tt,a[25];
int main()
{
	scanf("%d",&t);
	while(t--)
	{
		int i,j,cur=0,flag=1,b[2][25]={0},s1=0,s2=0;
		for(i=1;i<=15;i++)
			scanf("%d",&a[i]);
		int f1=0,f2=0;
		while(1)
		{
			int f=1;
			if(cur==0)
			{
				for(i=0;i<14;i++)
					if(a[p1[i]]>0)
					{
						f=0;
						break;
					}
				if(f)
					f1=1;
				if(f1&&f2)
					break;
				a[p1[i]]--;
				s1+=c1[p1[i]-1];
				s2+=d2[p1[i]-1];
			}
			else
			{
				for(i=0;i<14;i++)
					if(a[p2[i]]>0)
					{
						f=0;
						break;
					}
				if(f)
					f2=1;
				if(f1&&f2)
					break;
				a[p2[i]]--;
				s2+=c2[p2[i]-1];
				s1+=d1[p2[i]-1];
			}
			cur^=1;
		}
		printf("Case #%d: %s\n",++tt,s1>s2?"Alice":"Bob");
	}
}


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值