码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 4461 The Power of Xiangqi

时间:2015-05-18 19:01:54      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:区域赛   hdu   入门   最水题   

题目链接:The Power of Xiangqi


题面:

The Power of Xiangqi

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1780    Accepted Submission(s): 922


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.
 

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
3 2 A B 2 A B 7 A A B C D D F 7 A A B B C C F 5 A A B B F 3 A B F
 

Sample Output
tie black red
 

Source


题意:

     水题,就是算和,看谁大,马炮不能全有的时候,且分数大于1分,其分数减一分。


代码:

#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
   int n,red,black,store_red[7],store_black[7],score_red,score_black;
   int mark[7]={16,7,8,1,1,2,3};
   char tmp;
   cin>>n;
   for(int i=0;i<n;i++)
   {
     
   	 score_black=score_red=0;
 	 memset(store_red,0,sizeof(store_red));
 	 memset(store_black,0,sizeof(store_black));
   	 cin>>red;
   	 for(int j=0;j<red;j++)
   	 {
   	 	cin>>tmp;
		store_red[tmp-'A']++;
   	 }
   	 scanf("%d",&black);
   	 for(int j=0;j<black;j++)
   	 {
   	 	cin>>tmp;
		store_black[tmp-'A']++;
   	 }
   	 for(int j=0;j<7;j++)
   	 {
 	   score_red+=store_red[j]*mark[j];  
       score_black+=store_black[j]*mark[j];	
     }
     if(!(store_red[1]&&store_red[2])&&score_red>1)
     score_red-=1;
     if(!(store_black[1]&&store_black[2])&&score_black>1)
     score_black-=1;
     if(score_red>score_black)printf("red\n");
     else if(score_black>score_red)printf("black\n");
     else printf("tie\n");
   }
   return 0;	
}


HDU 4461 The Power of Xiangqi

标签:区域赛   hdu   入门   最水题   

原文地址:http://blog.csdn.net/david_jett/article/details/45824193

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!