HDU 4461:The Power of Xiangqi(水题)

http://acm.hdu.edu.cn/showproblem.php?pid=4461

题意:每个棋子有一个权值,给出红方的棋子情况,黑方的棋子情况,问谁能赢。

思路:注意“ if a player has no Ma or no Pao, or has neither, his total offense power will be decreased by one”这句话即可。

 #include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <iostream>
#include <stack>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
#define N 100010
#define INF 0x3f3f3f3f
int s[] = {, , , , , , , };
int mp1[], mp2[]; int main()
{
, ;
int t;
scanf("%d", &t);
while(t--) {
int red = , bla = ;
memset(mp1, , sizeof(mp1));
memset(mp2, , sizeof(mp2));
int n; char str[];
for(int i = ; i <= ; i++) {
scanf("%d", &n);
if(i == ) {
for(int j = ; j < n; j++) {
scanf("%s", str);
red += s[str[]-'A'+];
mp1[str[]-'A'+]++;
}
} else {
for(int j = ; j < n; j++) {
scanf("%s", str);
bla += s[str[]-'A'+];
mp2[str[]-'A'+]++;
}
}
}
if(mp1[] == || mp1[] == ) if(red > ) red--;
if(mp2[] == || mp2[] == ) if(bla > ) bla--;
if(red == bla) puts("tie");
else if(red < bla) puts("black");
else puts("red");
}
return ;
}
上一篇:ThinkPHP 3.2.3 简单后台模块开发(一)常用配置


下一篇:HDU 4461 The Power of Xiangqi (水题)