1 solutions

  • 0
    @ 2024-12-20 22:52:19

    C++ :

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    using namespace std;
    string s;char a;
    int main()
    {
    int i,x=0,y=0;
    cin>>a;
    if(a=='E') 
    {
    cout<<"0:0"<<endl;
    cout<<endl<<"0:0";
    return 0;
    }
    while(a!='E')
    {
        s+=a;
    	cin>>a;
    }
    for(i=0;i<s.size();i++)
    {
    if(s[i]=='W')
    x++;
    else if(s[i]=='L')
    y++;
    if((x>=11||y>=11)&&abs(x-y)>=2)
    {
    cout<<x<<":"<<y<<endl;
    x=0;
    y=0;
    }
    if(i==s.size()-1)
    {
    cout<<x<<":"<<y<<endl;
    continue;
    }
    }
    cout<<endl;
    x=0;
    y=0;
    for(i=0;i<s.size();i++)
    {
    if(s[i]=='W')
    x++;
    else if(s[i]=='L')
    y++;
    if((x>=21||y>=21)&&abs(x-y)>=2)
    {
    cout<<x<<":"<<y<<endl;
    x=0;
    y=0;
    }
    if(i==s.size()-1)
    {
    cout<<x<<":"<<y<<endl;
    continue;
    }
    }
    return 0;
    }
    
    • 1

    Information

    ID
    793
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    4
    Accepted
    2
    Uploaded By