【杭州赛区现场赛PROBLEM I】阅读理解与模拟-The Power of Xiangqi

来源:2012.11.04,2012 Asia Hangzhou Regional Contest,PROBLEM I,点击打开链接

这个题主要考阅读理解,主要是解决双方所剩象棋的战力问题,简单模拟。

但相比那个坑爹的求平方和,并不是说一点TRAP没有。

Since Ma and Pao working together can have good effect, if a player has no Ma or no Pao, or has neither(1), his total offense power will be decreased by one. But the total offense power can't be decreased to zero, it is at least one(2).

1的意思是,没有马||炮和没有马&&炮,效果是一样的,都是战斗力减一,不叠加。

2的意思是,战斗力最多减到一。如下测试数据应该判tie而不是RED WIN。

1

2 D E 

1 D

(结果是,TIE)

#include <iostream>
#include <string>
using namespace std;

int main()
{
    int testcase;
    cin>>testcase;
    while (testcase--)
    {
        int redpao=0,redma=0,blackma=0,blackpao=0;
        int redresult=0,blackresult=0;
        char tmp;


        int rednum;
        cin>>rednum;

        for (int i=0;i<rednum;i++)
        {
            cin>>tmp;
            if (tmp=='A')
                redresult+=16;
            if (tmp=='B')
            {
                redresult+=7;
                redma++;
            }
            if (tmp=='C')
            {
                redresult+=8;
                redpao++;
            }
            if (tmp=='D')
                redresult+=1;
            if (tmp=='E')
                redresult+=1;
            if (tmp=='F')
                redresult+=2;
            if (tmp=='G')
                redresult+=3;
        }
        if (redma==0 || redpao==0)
        {
            	redresult--;
        
        }
        if (redresult<=0)
        {
            redresult=1;
        }

        int blacknum;
        cin>>blacknum;
        for (int j=0;j<blacknum;j++)
        {
            cin>>tmp;
            if (tmp=='A')
                blackresult+=16;
            if (tmp=='B')
            {
                blackresult+=7;
                blackma++;
            }
            if (tmp=='C')
            {
                blackresult+=8;
                blackpao++;
            }
            if (tmp=='D')
                blackresult+=1;
            if (tmp=='E')
                blackresult+=1;
            if (tmp=='F')
                blackresult+=2;
            if (tmp=='G')
                blackresult+=3;
        }
        if (blackma==0||blackpao==0)
        {
            blackresult--;
           
   	        if (blackresult<=0)
        	{
            	blackresult=1;
        	}
        }


        if (redresult==blackresult)
        {
            cout<<"tie"<<endl;
        }
        if (redresult>blackresult)
        {
            cout<<"red"<<endl;
        }
        if (redresult<blackresult)
        {
            cout<<"black"<<endl;
        }

    }
    return 0;
}



最后,庆祝一下我的博客开通仅仅一个月便拥有了5000+的访问量,我会再接再厉的。

你可能感兴趣的:(【杭州赛区现场赛PROBLEM I】阅读理解与模拟-The Power of Xiangqi)