HDU 4461:The Power of Xiangqi(水题)

Posted Shadowdsp

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 }

 

以上是关于HDU 4461:The Power of Xiangqi(水题)的主要内容,如果未能解决你的问题,请参考以下文章

DSP - Measure the Power of a Signal

HDU 6623 Minimal Power of Prime(思维)题解

TED+成长性思维+Carol Deweck+The Power of Yet

CF1005C Summarize to the Power of Two 暴力 map

The KEY Point of Coffee Lake Power on

Summarize to the Power of Two(map+思维)