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. Kotlin语言Web库又添一虎将:Kweb

    Kweb是一个库,您可以利用它使用Kotlin编程语言轻松构建Web应用程序.从程序员的角度来看,它基本上消除了浏览器和服务器之间的分离.这意味着只操纵DOM的事件不需要进行服务器往返.由于Kweb是 ...

  2. MIPI接口LCD屏调试心得(转)

    源: MIPI接口LCD屏调试心得

  3. P3313 [SDOI2014]旅行

    P3313 [SDOI2014]旅行 树链剖分+动态线段树(并不是lct) 显然的,我们对于每一个宗教都要维护一个线段树. (那么空间不是爆炸了吗) 在这里引入:动态开点线段树 就是需要的点开起来,不 ...

  4. Python3 itchat微信获取好友、公众号、群聊的基础信息

    Python3 itchat微信获取好友.公众号.群聊的基础信息 一.简介 安装 itchat pip install itchat 使用个人微信的过程当中主要有三种账号需要获取,分别为: 好友 公众 ...

  5. log4j 根据类名指定文件

    log4j.logger.io.netty=INFO, stdout, spiderlog4j.logger.com.ld.net.spider=INFO, stdout, spider log4j. ...

  6. JavaScript DOM 元素属性 状态属性

    JavaScript DOM 元素属性 状态属性 版权声明:未经允许,严禁转载! 元素的属性 核心 DOM 为我们提供了操作元素标准属性的统一 API. 所有属性节点都储存在元素的 attribute ...

  7. 20145304 刘钦令 Exp2 后门原理与实践

    20145304 刘钦令 Exp2 后门原理与实践 基础问题回答 (1)例举你能想到的一个后门进入到你系统中的可能方式? 浏览网页时,或许会触发网站中隐藏的下载代码,将后门程序下载到默认地址. 下载的 ...

  8. DDR2是什么意思

    DDR2DDR2(Double Data Rate 2) SDRAM是由JEDEC(电子设备工程联合委员会)进行开发的新生代内存技术标准,它与上一代DDR内存技术标准最大的不同就是,虽然同是采用了在时 ...

  9. Python3基础 yield 在函数中的用法示例

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  10. Open Source Log Management

    https://www.elastic.co/solutions/logging The Elastic Stack (sometimes known as the ELK Stack) is the ...