HDU 4461 The Power of Xiangqi(水)

來源:互聯網
上載者:User

剛見到這個題目以為又是什麼類比,一堆位置關係,什麼你吃我我吃你,將軍什麼的,讀完題目之後發現就是個水題,能不能先A關鍵在能不能早點發現這個題

#include <iostream>#include <string.h>#include <stdio.h>using namespace std;int map[10]={16,7,8,1,1,2,3};char str[10];int red[20],black[20];int ans_red;int ans_black;int n,m;int main(){    int t;    int i,j,k;    scanf("%d",&t);    while(t--)    {        ans_red=ans_black=0;        memset(red,0,sizeof(red));        memset(black,0,sizeof(black));        scanf("%d",&n);        for(i=0;i<n;i++)        {            scanf("%s",str);            red[str[0]-'A']++;        }        scanf("%d",&m);        for(i=0;i<m;i++)        {            scanf("%s",str);            black[str[0]-'A']++;        }        for(i=0;i<7;i++)        ans_red+=map[i]*red[i];        for(i=0;i<7;i++)        ans_black+=map[i]*black[i];        if(!(red[1]&&red[2]))        {            ans_red--;        if(ans_red<=0)        ans_red=1;        }        if(!(black[1]&&black[2]))        {        ans_black--;        if(ans_black<=0)        ans_black=1;        }      //  printf("%d %d\n",ans_red,ans_black);        if(ans_red>ans_black)        printf("red\n");        else if(ans_red==ans_black)        printf("tie\n");        else        printf("black\n");    }    return 0;}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.