现在的位置: 首页 > 综合 > 正文

hdu 4461 The Power of Xiangqi(水题)

2019年08月19日 ⁄ 综合 ⁄ 共 535字 ⁄ 字号 评论关闭

题目链接:hdu 4461 The Power of Xiangqi

题目大意:两方下象棋,给定两方剩余棋子的种类,根据能力值评估胜者,特殊条件为如果没有马或者炮,战斗力要减

1,如果本来就是1就不用减了。

解题思路:水题,模拟计算。

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int g[10] = {16, 7, 8, 1, 1, 2, 3};

int solve () {
    char s[3];
    int n, ret = 0, v[10];
    memset(v, 0, sizeof(v));

    scanf("%d", &n);
    while (n--) {
        scanf("%s", s);
        int id = s[0] - 'A';
        ret += g[id];
        v[id] = 1;
    }

    if ((v[1] == 0 || v[2] == 0) && ret != 1)
        ret--;
    return ret;
}

int main () {
    int cas;
    scanf("%d", &cas);
    while (cas--) {
        int l = solve();
        int r = solve();
        if (l == r)
            printf("tie\n");
        else
            printf("%s\n", l > r ? "red" : "black");
    }
    return 0;
}

抱歉!评论已关闭.