1018. 锤子剪刀布 (20)

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char a,b;
    int p=0,y=0,s=0;
    int Pb=0,Pc=0,Pj=0;
    int b1=0,c1=0,j1=0;
    while(n--)
    {
        cin>>a>>b;
        if(a=='B'&&b=='B')
            p++;
        else if(a=='B'&&b=='C')
        {
            y++;
            Pb++;
        }

        else if(a=='B'&&b=='J')
        {
            s++;
            j1++;
        }

        else if(a=='C'&&b=='C')
            p++;
        else if(a=='C'&&b=='B')
        {
            s++;
            b1++;
        }

        else if(a=='C'&&b=='J')
        {
            y++;
            Pc++;
        }

        else if(a=='J'&&b=='J')
            p++;
        else if(a=='J'&&b=='B')
        {
             y++;
             Pj++;
        }

        else if(a=='J'&&b=='C')
        {
            s++;
            c1++;
        }

    }
    //cout<<Pb<<" "<<Pc<<" "<<Pj<<endl;
    //cout<<b1<<" "<<c1<<" "<<j1<<endl;
    cout<<y<<" "<<p<<" "<<s<<endl;
    cout<<s<<" "<<p<<" "<<y<<endl;
    if(Pb>Pc&&Pb>Pj)
        cout<<"B ";
    else if(Pc>Pb&&Pc>Pj)
        cout<<"C ";
    else if(Pj>Pc&&Pj>Pb)
        cout<<"J ";
    else if(Pb==Pc&&Pj<Pb)
        cout<<"C ";
    else if(Pb==Pj&&Pc<Pb)
        cout<<"B ";
    else if(Pj==Pc&&Pj>Pb)
            cout<<"C ";
    else
    {
        cout<<"B ";
    }
    if(b1>c1&&b1>j1)
        cout<<"B"<<endl;
    else if(c1>b1&&c1>j1)
        cout<<"C"<<endl;
    else if(j1>c1&&j1>b1)
        cout<<"J"<<endl;
    else if(b1==c1&&j1<b1)
        cout<<"C ";
    else if(b1==j1&&c1<b1)
        cout<<"B ";
    else if(j1==c1&&j1>b1)
            cout<<"C ";
    else
    {
        cout<<"B"<<endl;
    }
    return 0;
}
这题思路很简单,就是过程麻烦了,最后的18分,发现解不唯一,则输出按字母序最小的解。这个没有判断
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值