Loading

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”这句话即可。

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <cmath>
 4 #include <cstdlib>
 5 #include <algorithm>
 6 #include <string>
 7 #include <iostream>
 8 #include <stack>
 9 #include <map>
10 #include <queue>
11 #include <set>
12 using namespace std;
13 typedef long long LL;
14 #define N 100010
15 #define INF 0x3f3f3f3f
16 int s[] = {0, 16, 7, 8, 1, 1, 2, 3};
17 int mp1[15], mp2[15];
18 
19 int main()
20 {
21     2, 3;
22     int t;
23     scanf("%d", &t);
24     while(t--) {
25         int red = 0, bla = 0;
26         memset(mp1, 0, sizeof(mp1));
27         memset(mp2, 0, sizeof(mp2));
28         int n; char str[3];
29         for(int i = 1; i <= 2; i++) {
30             scanf("%d", &n);
31             if(i == 1) {
32                 for(int j = 0; j < n; j++) {
33                     scanf("%s", str);
34                     red += s[str[0]-'A'+1];
35                     mp1[str[0]-'A'+1]++;
36                 }
37             } else {
38                 for(int j = 0; j < n; j++) {
39                     scanf("%s", str);
40                     bla += s[str[0]-'A'+1];
41                     mp2[str[0]-'A'+1]++;
42                 }
43             }
44         }
45         if(mp1[2] == 0 || mp1[3] == 0) if(red > 0) red--;
46         if(mp2[2] == 0 || mp2[3] == 0) if(bla > 0) bla--;
47         if(red == bla) puts("tie");
48         else if(red < bla) puts("black");
49         else puts("red");
50     }
51     return 0;
52 }

 

posted @ 2017-01-18 23:23  Shadowdsp  阅读(200)  评论(0编辑  收藏  举报