求助

P1042 [NOIP2003 普及组] 乒乓球

Future_Comet @ 2024-07-11 17:58:26

样例全过,其余……听取WA声一片。 代码如下,求神犇解:

#include<bits/stdc++.h>
using namespace std;
char c;
bool f[62530];
int k,a,b;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    while(c!='E')
        cin>>c,k++,f[k]=(c=='W')?1:0;
    k--;
    cout<<endl;
    for(int i=1;i<=k;i++)
    {
        if((i-1)%11==0&&i!=1)
            cout<<a<<":"<<b<<endl,a=b=0;
        (f[i]==1)?a++:b++;
    }
    cout<<a<<":"<<b<<endl<<endl;
    a=b=0;
    for(int i=1;i<=k;i++)
    {
        if((i-1)%21==0&&i!=1)
            cout<<a<<":"<<b<<endl,a=b=0;
        (f[i]==1)?a++:b++;
    }
    cout<<a<<":"<<b<<endl<<endl;
    return 0;
}

|