hdu-4023-博弈(模拟)

时间:2024-06-15 15:04:26

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.
hdu-4023-博弈(模拟)
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 ;
}