HDU 4461 The Power of Xiangqi (水题)

题意:给定一些字母,每个字母都代表一值,如果字母中没有B,或者C,那么就在总值大于1的条件下删除1,然后比较大小。

析:没什么好说的,加起来比较就好了。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>

using namespace std ;
typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1e5 + 5;
const int dr[] = {0, 0, -1, 1};
const int dc[] = {-1, 1, 0, 0};
int n, m;
inline bool is_in(int r, int c){
    return r >= 0 && r < n && c >= 0 && c < m;
}
map<char, int> mp;

int main(){
    mp['A'] = 16;
    mp['B'] = 7;
    mp['C'] = 8;
    mp['D'] = 1;
    mp['E'] = 1;
    mp['F'] = 2;
    mp['G'] = 3;
    int T;  cin >> T;
    while(T--){
        scanf("%d", &n);
        char s[5];
        int ans1 = 0, ans2 = 0;
        int h1 = 0, h2 = 0;
        int c1 = 0, c2 = 0;
        for(int i = 0; i < n; ++i){
            scanf("%s", s);
            ans1 += mp[s[0]];
            if(s[0] == 'B')  ++c1;
            else if(s[0] == 'C')  ++h1;
        }
        if(!c1 || !h1){
            if(ans1 > 1)  --ans1;
        }
        scanf("%d", &m);
        for(int i = 0; i < m; ++i){
            scanf("%s", s);
            ans2 += mp[s[0]];
            if(s[0] == 'B')  ++c2;
            else if(s[0] == 'C')  ++h2;
        }
        if(!c2 || !h2){
            if(ans2 > 1)  --ans2;
        }
        if(ans1 > ans2)  puts("red");
        else if(ans1 < ans2)  puts("black");
        else puts("tie");
    }
    return 0;
}
原文地址:https://www.cnblogs.com/dwtfukgv/p/5750585.html