Game

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

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
 
  其实方法还是不难想的,由于数据不大可以模拟博弈过程,我们只要知道对于每一方,先占领那种砖块对自己更有利就可以直接模拟了,最后统计一下各自剩余步数就好了。
  对于Alice,(15)>(3,4,5,6)>(11,12,13,14)>(7,8)>(9,10)
  对于Bob,(15)>(3,4,5,6)>(11,12,13,14)>(9,10)>(7,8)
 #include<bits/stdc++.h>
using namespace std;
int num[];
int main(){
int t,i,j,k,n,m;
cin>>t;
for(int cas=;cas<=t;++cas){
int tot1=,tot2=;
bool op=,ok=;
for(i=;i<;++i) cin>>num[i];
tot1+=num[]*,num[]=;
tot2+=num[]*,num[]=;
while(ok){
if(op==){
if(num[]){
num[]--;
tot1++;
}
else if(num[]){
num[]--;
}
else if(num[]){
num[]--;
}
else if(num[]){
num[]--;
tot1++;
}
else if(num[]){
num[]--;
tot1++;
}
else if(num[]){
num[]--;
}
else if(num[]){
num[]--;
}
else if(num[]){
num[]--;
}
else if(num[]){
num[]--;
}
else if(num[]){
num[]--;
}
else if(num[]){
num[]--;
}
else if(num[]){
num[]--;
tot2++;
}
else if(num[]){
num[]--;
tot2++;
}
else if(tot1){
tot1--;
}
else{
break;
}
op=;
}
else{
if(num[]){
num[]--;
tot2++;
}
else if(num[]){
num[]--;
tot2++;
}
else if(num[]){
num[]--;
tot2++;
}
else if(num[]){
num[]--;
}
else if(num[]){
num[]--;
}
else if(num[]){
num[]--;
}
else if(num[]){
num[]--;
}
else if(num[]){
num[]--;
}
else if(num[]){
num[]--;
}
else if(num[]){
num[]--; }
else if(num[]){
num[]--;
} else if(num[]){
num[]--;
tot1++;
}
else if(num[]){
num[]--;
tot1++;
}
else if(tot2){
tot2--;
}
else{
break;
}
op=;
}
}
printf("Case #%d: ",cas);
if(op) tot2--;
tot1>tot2?puts("Alice"):puts("Bob");
}
return ;
}

hdu-4023-博弈(模拟)的更多相关文章

  1. HDU 4023 (博弈 贪心 模拟) Game

    如果硬要说这算是博弈题目的话,那这个博弈是不公平博弈(partizan games),因为双方面对同一个局面做出来的决策是不一样的. 我们平时做的博弈都是公平博弈(impartial games),所 ...

  2. S-Nim HDU 1536 博弈 sg函数

    S-Nim HDU 1536 博弈 sg函数 题意 首先输入K,表示一个集合的大小,之后输入集合,表示对于这对石子只能去这个集合中的元素的个数,之后输入 一个m表示接下来对于这个集合要进行m次询问,之 ...

  3. hdu 4023 2011上海赛区网络赛C 贪心+模拟

    以为是贪心,结果不是,2333 贪心最后对自己绝对有利的情况 点我 #include<cstdio> #include<iostream> #include<algori ...

  4. HDU 4121 Xiangqi 模拟题

    Xiangqi Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4121 ...

  5. hdu 5071 Chat(模拟)

    题目链接:hdu 5071 Chat 题目大意:模拟题. .. 注意最后说bye的时候仅仅要和讲过话的妹子说再见. 解题思路:用一个map记录每一个等级的妹子讲过多少话以及是否有这个等级的妹子.数组A ...

  6. hdu 4740【模拟+深搜】.cpp

    题意: 给出老虎的起始点.方向和驴的起始点.方向.. 规定老虎和驴都不会走自己走过的方格,并且当没路走的时候,驴会右转,老虎会左转.. 当转了一次还没路走就会停下来.. 问他们有没有可能在某一格相遇. ...

  7. HDU 2568[前进]模拟

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2568 关键思想:傻傻地模拟 代码如下: #include<iostream> using ...

  8. hdu 4964 恶心模拟

    http://acm.hdu.edu.cn/showproblem.php?pid=4964 给定语句,按照语法翻译html并输出. 就是恶心的模拟,递归搞就行了 处理id和class时,在一个'&g ...

  9. HDU 5996 博弈

    http://acm.hdu.edu.cn/showproblem.php?pid=5996 博弈论待补. 这题变化了一下,因为注意到奇数层的东西(层数从1开始),对手可以模仿地动,那就相当于没动. ...

  10. HDU 4994 博弈。

    F - 6 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

随机推荐

  1. Arduino使用HC05蓝牙模块与手机连接

    Arduino使用HC05蓝牙模块与手机连接 一切都是最好的选择 首先是线路连接,一定不要接错了 Arduino 代码 #include <SoftwareSerial.h> // Pin ...

  2. 微信小程序——1、文件的认识

    主体文件的构成 微信小程序的主体由三个部分组成,需放在主目录中,名称也是固定的 app.js:微信小程序的主逻辑文件,主要用来注册小程序 app.json:微信小程序的主配置文件,对微信小程序进行全局 ...

  3. ACM数论之旅6---数论倒数,又称逆元(我整个人都倒了( ̄﹏ ̄))

    数论倒数,又称逆元(因为我说习惯逆元了,下面我都说逆元) 数论中的倒数是有特别的意义滴 你以为a的倒数在数论中还是1/a吗 (・∀・)哼哼~天真 先来引入求余概念 (a +  b) % p = (a% ...

  4. [noip模拟题]LGTB 玩THD

    LGTB 最近在玩一个类似DOTA 的游戏名叫THD 有一天他在守一座塔,对面的N 个小兵排成一列从近到远站在塔前面每个小兵有一定的血量hi,杀死后有一定的金钱gi 每一秒,他都可以攻击任意一个活着的 ...

  5. Asp.net简单概念知识

    1. 简述 private. protected. public. internal 修饰符的访问权限.答 . private :   私有成员, 在类的内部才可以访问.      protected ...

  6. Django Python MySQL Linux 开发环境搭建

    Django Python MySQL Linux 开发环境搭建 1.安装Python 进行Python开发,首先必须安装python,对于linux 或者Mac 用户,python已经预装. 在命令 ...

  7. asp.net <asp:Repeater>下的radio的单选使用

    aspx页面 <asp:Repeater ID="rptData" runat="server"> <ItemTemplate> < ...

  8. hdu 5525 Product 数论算贡献

    Product Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Proble ...

  9. shell 布尔运算

    布尔运算 Bash 里的逻辑运算,与.或.非. 在 Shell 下如何进行逻辑运算 范例:true or false 单独测试 true 和 false,可以看出 true 是真值,false 为假 ...

  10. resource not found :rgbd_launch

    放到src下,再次编译catkin_make git https://github.com/ros-drivers/rgbd_launch.git