40分大佬求解
查看原帖
40分大佬求解
516508
windfall_waterfall楼主2022/7/5 16:32

这是40分的代码

#include<bits/stdc++.h>
using namespace std;
int el[10001],ew[10001],tl[10001],tw[10001],ec=1,tc=1;
int main(){
    int cnt=0;
    char s[1000001];
    while(cin>>s[++cnt]){
        if(s[cnt]=='E') break;
        if(el[ec]==11 || ew[ec]==11) ec++;
        if(tl[tc]==21 || tw[tc]==21) tc++;
        if(s[cnt]=='W'){
            ew[ec]++;
            tw[tc]++;
        }
        if(s[cnt]=='L'){
            el[ec]++;
            tl[tc]++;
        }
    }
    for(int i=1 ; i<=ec ; i++){
        cout<<ew[i]<<":"<<el[i]<<endl;
    }
    cout<<endl;
    for(int i=1 ; i<=tc ; i++){
        cout<<tw[i]<<":"<<tl[i]<<endl;
    }
    return 0;
}
2022/7/5 16:32
加载中...