HDU-4461-The Power of Xiangqi
来源:互联网 发布:unity3d自学教程 编辑:程序博客网 时间:2024/05/17 16:13
The Power of Xiangqi
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1420 Accepted Submission(s): 775
Problem Description
Xiangqi is one of the most popular two-player board games in China. The game represents a battle between two armies with the goal of capturing the enemy’s “general” piece.
Now we introduce some basic rules of Xiangqi. Xiangqi is played on a 10×9 board and the pieces are placed on the intersections (points). There are two groups of pieces marked by black or red Chinese characters, belonging to the two players separately. During the game, each player in turn moves one piece from the point it occupies to another point. No two pieces can occupy the same point at the same time. A piece can be moved onto a point occupied by an enemy piece, in which case the enemy piece is "captured" and removed from the board. When the general is in danger of being captured by the enemy player on the enemy player’s next move, the enemy player is said to have "delivered a check". If the general's player can make no move to prevent the general's capture by next enemy move, the situation is called “checkmate”.
Each player has 7 kinds of pieces in this game. Their names, offense power and symbol letters are shown in the table below:
Now show you the pieces of red player and black player, you are going to find out which player has the larger total offense power. Since Ma and Pao working together can have good effect, if a player has no Ma or no Pao, or has neither, his total offense power will be decreased by one. But the total offense power can't be decreased to zero, it is at least one.
Input
The first line is an integer T ( T <= 20) meaning there are T test cases.
For each test case: The first line shows which pieces the red player has. It begins with an integer n ( 0 < n <= 16) meaning the number of pieces.
Then n letters follows, all separated by one or more blanks. Each letter is a symbol letter standing for a piece, as shown in the table above.
The second line describes the situation of the black player, in the same format as the first line.
For each test case: The first line shows which pieces the red player has. It begins with an integer n ( 0 < n <= 16) meaning the number of pieces.
Then n letters follows, all separated by one or more blanks. Each letter is a symbol letter standing for a piece, as shown in the table above.
The second line describes the situation of the black player, in the same format as the first line.
Output
For each test case, if the red player has more offense power, then print "red". If the black player has more offense power, then print "black". If there is a tie, print "tie".
Sample Input
32 A B2 A B7 A A B C D D F 7 A A B B C C F5 A A B B F3 A B F
Sample Output
tieblackred
Source
2012 Asia Hangzhou Regional Contest
昨天去实验室刷的水题。。挺简单的,不过还是失误了,输入字符的时候要吸收之后回车,不然就用字符串!
题意:就是算total power , 但是注意了,当没马或没炮或两者都没的时候total power 会减少1,且total power 最少为1!
水题还是要多多注意的!!不然就WA了
代码:
#include <cstdio> #include <cstring>using namespace std;bool A, B;int fun(char a){if(a == 'A')return 16;if(a == 'B')return 7;if(a == 'C')return 8;if(a == 'D')return 1;if(a == 'E')return 1;if(a == 'F')return 2;if(a == 'G')return 3;}int main(){int T;scanf("%d", &T);while(T--){char a[3];int n1, n2, sum1=0, sum2=0;scanf("%d", &n1);A=0; B=0;while(n1--){scanf("%s", a);sum1+=fun(a[0]); if(a[0]=='B') A=1;if(a[0]=='C') B=1;}if(A==0||B==0) sum1--;if(sum1==0) sum1=1;scanf("%d", &n2);A=0; B=0;while(n2--){scanf("%s", a);sum2+=fun(a[0]);if(a[0]=='B') A=1;if(a[0]=='C') B=1;}if(A==0||B==0) sum2--;if(sum2==0) sum2=1;if(sum1>sum2) printf("red\n");else if(sum1 == sum2) printf("tie\n");else if(sum1<sum2) printf("black\n");}return 0;}
1 0
- hdu(4461) The Power of Xiangqi
- HDU 4461 The Power of Xiangqi
- HDU-#4461 The Power of Xiangqi
- HDU-4461-The Power of Xiangqi
- hdu 4461 The Power of Xiangqi(水题)
- HDU 4461 The Power of Xiangqi
- HDU 4461 The Power of Xiangqi
- HDU 4461 The Power of Xiangqi(水)
- hdu 4461 The Power of Xiangqi(水题)
- HDU 4461 The Power of Xiangqi(水)
- hdu 4461 The Power of Xiangqi【模拟】水题
- hdu 4461 The Power of Xiangqi(简单模拟)
- HDU4461:The Power of Xiangqi
- hdu4461 The Power of Xiangqi
- HDU4461 The Power of Xiangqi
- The Power of Xiangqi(水题)
- hdu4461 The Power of Xiangqi【水题】
- 【杭州赛区现场赛PROBLEM I】阅读理解与模拟-The Power of Xiangqi
- opencl
- Android使用ViewPager实现左右循环滑动及轮播效果
- SQL Server 2008如何copy database
- (译)OpenGL ES2.0 – Iphone开发指引
- Express4.x安装
- HDU-4461-The Power of Xiangqi
- JAVA模拟银行存钱,取钱操作以及计算利息操作
- Android 最火的快速开发框架AndroidAnnotations使用详解
- Ucgui列表
- 定时任务中,cronExpression的设置规则
- matlab读取img格式文件
- 在Express中安装XTemplate
- XMPP会议室设置MUC
- LAMP几个常用配置