• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
dwtfukgv
博客园    首页    新随笔    联系   管理    订阅  订阅
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;
}

 

posted on 2016-08-08 18:44  dwtfukgv  阅读(134)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3