洛谷 交叉模拟

P1042 乒乓球

#include <bits/stdc++.h>
using namespace std;
char x[62590];
int h11[62500],d11[62500];
int h21[62500],d21[62500];
int main()
{
    for(int i=0;; i++)
    {
        cin>>x[i];//注意本题中分行输入的方法
        if(x[i]=='E')
            break;
    }
    int k=0;
    for(int i=0; x[i]!='E'; i++)
    {
        if(x[i]=='W')
            h11[k]++;
        else if(x[i]=='L')
            d11[k]++;
        if(max(d11[k],h11[k])>=11&&(max(d11[k],h11[k])-min(d11[k],h11[k]))>=2)
            k++;
    }
    for(int j=0; j<=k; j++)
        cout<<h11[j]<<":"<<d11[j]<<endl;
    cout<<endl;
    int t=0;
    for(int i=0; x[i]!='E'; i++)
    {
        if(x[i]=='W')
            h21[t]++;
        else if(x[i]=='L')
            d21[t]++;
        if(max(d21[t],h21[t])>=21&&(max(d21[t],h21[t])-min(d21[t],h21[t]))>=2)
            t++;
    }
    for(int j=0; j<t; j++)
        cout<<h21[j]<<":"<<d21[j]<<endl;
    cout<<h21[t]<<":"<<d21[t];
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_46126537/article/details/104238935
今日推荐