乒乓球

来源:互联网 发布:重装软件排名 编辑:程序博客网 时间:2024/04/28 08:59
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>using namespace std;char s[25];int t1=1,t2=1,p1[100001],q1[100001],p2[100001],q2[100001];int main(){    freopen("in.txt","r",stdin);    freopen("out2.txt","w",stdout);    while(cin>>s)    {        int len=strlen(s);        for(int i=0;i<len;i++)        {            if(s[i]=='W') {                p1[t1]++;p2[t2]++;                if(p1[t1]>=11 && abs(p1[t1]-q1[t1])>=2)t1++;                if(p2[t2]>=21 && abs(p2[t2]-q2[t2])>=2)t2++;            }            else if(s[i]=='L') {                q1[t1]++;q2[t2]++;                if(q1[t1]>=11 && abs(p1[t1]-q1[t1])>=2)t1++;                if(q2[t2]>=21 && abs(p2[t2]-q2[t2])>=2)t2++;            }            else if(s[i]=='E'){                for(int i=1;i<=t1;i++)                    cout<<p1[i]<<":"<<q1[i]<<endl;                cout<<endl;                for(int i=1;i<=t2;i++)                    cout<<p2[i]<<":"<<q2[i]<<endl;                return 0;            }        }    }}
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>using namespace std;string s;int t1=1,t2=1,p1[100001],q1[100001],p2[100001],q2[100001];inline bool read(string &s) {    s="";    int c=getchar();    while(c=='\r' || c=='\n' || c==' ' || c==0) c=getchar();    s.push_back(c);    while((c=getchar()) && c!='\r' && c!='\n' && c!=0 && c!=-1) s.push_back(c);    while(s[s.length()-1]==' ') s.resize(s.length()-1);    return true;}int main(){//  freopen("in.txt","r",stdin);//  freopen("out2.txt","w",stdout);    while(read(s))    {        int len=s.size();        for(int i=0;i<len;i++)        {            if(s[i]=='W') {                p1[t1]++;p2[t2]++;                if(p1[t1]>=11 && abs(p1[t1]-q1[t1])>=2)t1++;                if(p2[t2]>=21 && abs(p2[t2]-q2[t2])>=2)t2++;            }            else if(s[i]=='L') {                q1[t1]++;q2[t2]++;                if(q1[t1]>=11 && abs(p1[t1]-q1[t1])>=2)t1++;                if(q2[t2]>=21 && abs(p2[t2]-q2[t2])>=2)t2++;            }            else if(s[i]=='E'){                for(int i=1;i<=t1;i++)                    cout<<p1[i]<<":"<<q1[i]<<endl;                cout<<endl;                for(int i=1;i<=t2;i++)                    cout<<p2[i]<<":"<<q2[i]<<endl;                return 0;            }        }    }}
0 0