### 题目
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
代码分析:
刚开始以为很难的一道题,原来全篇介绍象棋是个啥,到后面才说主要意思,原来是水题一道。注意点:没炮没马,或者一方没有,战力值会减一,就当是练习输入和输出语句了。
ac代码:
//hdu-The Power of Xiangqi
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define N 30
using namespace std;
int main(){
int t;
cin>>t;
int n1,n2;
char ch1,ch2;
while(t--){
int sum1=0,sum2=0;
bool fma1=false,fpao1=false,fma2=false,fpao2=false;
cin>>n1;
while(n1--){
//int i=0;
cin>>ch1;
if(ch1=='A') sum1+=16;
else if(ch1=='B')
{
sum1+=7;
fma1=true;
}
else if(ch1=='C')
{
sum1+=8;
fpao1=true;
}
else if(ch1=='D') sum1+=1;
else if(ch1=='E') sum1+=1;
else if(ch1=='F') sum1+=2;
else if(ch1=='G') sum1+=3;
else sum1+=0;
//i++;
}
cin>>n2;
while(n2--){
//int i=0;
cin>>ch2;
if(ch2=='A') sum2+=16;
else if(ch2=='B')
{
sum2+=7;
fma2=true;
}
else if(ch2=='C')
{
sum2+=8;
fpao2=true;
}
else if(ch2=='D') sum2+=1;
else if(ch2=='E') sum2+=1;
else if(ch2=='F') sum2+=2;
else if(ch2=='G') sum2+=3;
else sum2+=0;
//i++;
}
if((fma1==false||fpao1==false))
sum1--;
if((fma2==false||fpao2==false))
sum2--;
if(sum1==sum2)
cout<<"tie\n";
else if(sum1>sum2)
cout<<"red\n";
else
cout<<"black\n";
}
return 0;
}