题解

381 条题解

  • -1
    @ 2019-06-17 13:36:41

    #include <iostream>
    using namespace std;
    int main(void) {
    char A[100000];
    int left = 0, right = 0;
    int i = 0;
    while ((A[i] = getchar()) != EOF) {
    if (A[i] == 'E')break;
    ++i;
    }
    i = 0;
    while (A[i] != 'E') {
    if (A[i] == 'W')
    ++left;
    else if (A[i] == 'L')
    ++right;
    if ((left >= 11 || right >= 11) && (left - right > 1 || right - left > 1)) {
    cout << left <<':'<< right << endl;
    left = right = 0;
    }
    ++i;
    }
    cout << left << ':' << right << endl;
    cout << endl;
    left = right = i = 0;
    while (A[i] != 'E') {
    if (A[i] == 'W')
    ++left;
    else if (A[i] == 'L')
    ++right;
    if ((left >= 21 || right >= 21) && (left - right > 1 || right - left > 1)) {
    cout << left << ':' << right << endl;
    left = right = 0;
    }
    ++i;
    }
    cout << left << ':' << right;
    return 0;
    }

  • -1
    @ 2019-05-31 21:35:40
    #include <iostream>
    #include <queue>
    using namespace std;
    
    class Result
    {
    public:
        int playerA;
        int playerB;
        int max;
        Result(int max)
        {
            this->max = max;
            playerA = 0;
            playerB = 0;
        }
        void add(char c)
        {
            if (c == 'W')
            {
                playerA++;
            }
            else
            {
                playerB++;
            }
        }
        bool isEnd()
        {
            return (playerA >= max && playerA - playerB > 1) ||
                   (playerB >= max && playerB - playerA > 1);
        }
    };
    class Recorder
    {
    public:
        queue<Result> records;
        int max;
    
        Recorder(int max)
        {
            this->max = max;
        }
        void add(char c)
        {
            prepareQueue();
            records.back().add(c);
        }
    
        void prepareQueue()
        {
            if (records.empty() || records.back().isEnd())
            {
                Result r(max);
                records.push(r);
            }
        }
    };
    ostream &operator<<(ostream &os, Result &r)
    {
        os << r.playerA << ":" << r.playerB;
        return os;
    }
    ostream &operator<<(ostream &os, Recorder &r)
    {
        if (r.records.empty())
        {
            os << "0:0" << endl;
        }
        while (!r.records.empty())
        {
            os << r.records.front() << endl;
            r.records.pop();
        }
        return os;
    };
    
    int main()
    {
        Recorder r11(11);
        Recorder r21(21);
        while (true)
        {
            char c;
            cin >> c;
            if (c == 'E' )
            {
                break;
            }
            if (c == 'W' || c == 'L')
            {
                r11.add(c);
                r21.add(c);
            }
        }
    
        // bug of the quiz: if previous game ends, it expect we have one more 0:0
        r11.prepareQueue();
        r21.prepareQueue();
    
        cout << r11 << endl
             << r21;
        return 0;
    }
    
  • -1
    @ 2019-03-22 19:26:31

    #include<iostream>
    #include<string>
    #include<math.h>
    using namespace std;
    int abs(int a){
    if(a<0) a=0-a;
    return a;
    }
    int main(){
    char a[100001];
    int w,l,i;
    w=0;
    l=0;
    i=1;
    while(cin>>a[i]&&a[i]!='E'){
    i+=1;
    }
    i=i-1;
    for(int k=1;k<=i;k++){
    if(a[k]=='W') w+=1;
    if(a[k]=='L') l+=1;
    if(w>=11||l>=11){
    if(abs(w-l)>=2){
    cout<<w<<":"<<l<<endl;
    w=0;
    l=0;
    }
    }
    }

    cout<<w<<":"<<l<<endl<<endl;
    w=0;
    l=0;

    for(int k=1;k<=i;k++){
    if(a[k]=='W') w+=1;
    if(a[k]=='L') l+=1;
    if(w>=21||l>=21){
    if(abs(w-l)>=2){
    cout<<w<<":"<<l<<endl;
    w=0;
    l=0;
    }
    }
    }

    cout<<w<<":"<<l<<endl<<endl;

    }

  • -1
    @ 2019-02-23 18:54:17

    感觉异常繁琐,又不知道怎么改...
    #include <stdio.h>

    int main()
    {
    int i=0,huahua=0,duishou=0,state=1;
    char n[2];
    int game[100000]={0};

    scanf("%1s",n);
    while (n[0]!='E')
    {

    if(n[0]=='W')
    {
    game[i]=1;
    }else if (n[0]=='L')
    {
    game[i]=2;

    }
    i++;
    scanf("%1s",n);
    }
    i=0;
    if (game[0]==0)
    {
    printf("0:0\n\n0:0");
    }else
    {
    while (game[i]!=0)
    {
    huahua=0;
    duishou=0;
    while ((((huahua<11)&&(duishou<11))||((huahua-duishou<2)&&(duishou-huahua<2)))&&(game[i]!=0))
    {
    if (game[i]==1)
    {
    huahua++;
    }else
    {
    duishou++;
    }
    i++;
    }
    printf("%d:%d\n",huahua,duishou);

    }
    if ((huahua+duishou)%11==0)
    {
    printf("0:0\n");
    }
    printf("\n");
    i=0;
    while (game[i]!=0)
    {

    huahua=0;
    duishou=0;
    while ((((huahua<21)&&(duishou<21))||((huahua-duishou<2)&&(duishou-huahua<2)))&&(game[i]!=0))
    {
    if (game[i]==1)
    {
    huahua++;
    }else
    {
    duishou++;
    }
    i++;
    }
    printf("%d:%d\n",huahua,duishou);
    }
    if ((huahua+duishou)%21==0)
    {
    printf("0:0");
    }
    }

    return 0;
    }

  • -1
    @ 2019-02-09 12:30:42

    好像有点繁琐了……

    #include <iostream>
    #include <cmath>
    using namespace std;
    
    int main(){
        int PointHua=0,PointDui=0,i=0,j=0,k=0;
        char rec[100000],cha;
        while (cin>>rec[i])
            i++;
        while (cha=rec[j]){
            j++;
            if (cha=='W') PointHua++;
            if (cha=='L') PointDui++;
            if (cha=='E') break;
            if (PointHua>=11||PointDui>=11){
                if (abs(PointHua-PointDui)>1){
                    cout<<PointHua<<':'<<PointDui<<endl;
                    PointHua=0;
                    PointDui=0;
                }
            }
        }
        cout<<PointHua<<':'<<PointDui<<endl;
        cout<<endl;
        PointHua=0;
        PointDui=0;
        while (cha=rec[k]){
            k++;
            if (cha=='W') PointHua++;
            if (cha=='L') PointDui++;
            if (cha=='E') break;
            if (PointHua>=21||PointDui>=21){
                if (abs(PointHua-PointDui)>1){
                    cout<<PointHua<<':'<<PointDui<<endl;
                    PointHua=0;
                    PointDui=0;
                }
            }
        }
        cout<<PointHua<<':'<<PointDui<<endl;
        return 0;
    }
    
  • -1
    @ 2018-12-26 23:17:15
    #Python 很繁琐,请多指教
    rawscorelist = list(input())
    scorelist = []
    while 'E' not in rawscorelist:
        scorelist.extend(rawscorelist)
        rawscorelist = list(input())
    for i in range(len(rawscorelist)):
        if rawscorelist[i] == 'E':
            break
        else:
            scorelist.append(rawscorelist[i])
    
    
    def test(A):
        X = 0
        Y = 0
        n = 0
        for i in scorelist:
            if i == "W":
                X = X + 1
            if i == 'L':
                Y = Y + 1
            if abs(X - Y) >= 2 and (X >= A or Y >= A):
                print("{}:{}".format(X, Y))
                X = Y = 0
    
        print("{}:{}".format(X, Y))
    
    
    test(11)
    print()
    test(21)
    
  • -1
    @ 2018-09-17 18:48:27
    2wwwwwwwwwwwwwwwwwwwwwwwwww
    
  • -1
    @ 2018-08-16 20:14:43

    #include<iostream>
    #include<cmath>
    using namespace std;
    int main()
    { char jilu[100000];
    for(int i=0;;i++)
    {
    cin>>jilu[i];
    if(jilu[i]=='E')
    break;

    }
    int x,y;
    x=0;y=0;
    for(int i=0;;i++)
    {
    if(jilu[i]=='W')
    x++;
    if(jilu[i]=='L')
    y++;

    if((x>=11||y>=11)&&abs(x-y)>=2)
    {
    cout<<x<<":"<<y<<endl;
    x=0;y=0;
    }
    if(jilu[i]=='E')
    {
    cout<<x<<":"<<y<<endl;
    break;

    }}
    x=0;y=0;
    cout<<endl;
    for(int i=0;;i++)
    {
    if(jilu[i]=='W')
    x++;
    if(jilu[i]=='L')
    y++;

    if((x>=21||y>=21)&&abs(x-y)>=2)
    {
    cout<<x<<":"<<y<<endl;
    x=0;y=0;
    }
    if(jilu[i]=='E')
    {
    cout<<x<<":"<<y<<endl;
    break;

    }}

    return 0;
    }

  • -1
    @ 2018-08-13 23:56:30

    加了注释的解决方案 适合C++
    #include<iostream>
    #include<string>
    #include<cstring>

    using std::endl;
    using std::cin;
    using std::cout;
    using std::string;

    void process(string, int);

    int main()
    {
    string resultline[100000]; //开1000个空间过不了,hhh
    string result;
    int nail = 0;
    while (1)
    {
    getline(cin, resultline[nail]);
    if (resultline[nail] == "") break;
    nail += 1;
    } //可能读到有E的,后面再处理
    for (int i = 0; i <= nail; i++)
    {
    result += resultline[i];
    }

    process(result, 11);
    cout<<endl;
    process(result, 21);

    return 0;
    }

    void process(string result, int s) //按不同标准进行处理
    {
    int i = 0;// 作为计数
    int hua = 0; //华华分数
    int huaop = 0; //华华对手分数
    while (1)
    {
    if (result[i] == 'W') hua += 1;
    if (result[i] == 'L') huaop += 1;
    if ( result[i] == 'E' ) break;
    i += 1;
    if ((((hua == s) || (huaop == s)) && (abs(hua - huaop) >= 2)) || (((hua>s)||(huaop>s)) && (abs(hua-huaop)==2))) //未加赛超两分,加赛直接超过两分进行下一局
    {
    cout << hua << ":" << huaop << endl;
    hua = huaop = 0;
    }
    }
    cout << hua << ":" << huaop << endl; // 最后一场没打满,但比分还在
    }

  • -1
    @ 2018-07-14 07:21:25

    #include<cstdio>

    using namespace std;
    char c[100000001];

    int main()
    {
    int i(0);
    while(scanf("%c",&c[++i])&&c[i]!='E');
    int m(0),n(0);
    for(int j=1;j<=i;++j)
    {
    if(c[j]=='W')++m;
    if(c[j]=='L')++n;
    if(m+n==11||j==i)
    {
    printf("%d:%d\n",m,n);
    m=0;n=0;
    }
    }
    m=0;n=0;
    printf("\n");
    for(int j=1;j<=i;++j)
    {
    if(c[j]=='W')++m;
    if(c[j]=='L')++n;
    if(m+n==21||j==i)
    {
    printf("%d:%d\n",m,n);
    m=0;n=0;
    }
    }

    return 0;
    }

    //哪里有错?样例全过。

  • -1
    @ 2018-07-11 15:26:37

    if name == '__main__':
    # with open("Demo3_test", 'r')as file:
    # string = file.read()
    string = ''
    while 1:
    s = input()
    string += s
    if s.find('E') != -1:
    break
    W_count = 0
    L_count = 0
    for i in string:
    if i == 'E':
    print(str(W_count) + ':' + str(L_count))
    break
    else:
    if i == 'W':
    W_count += 1
    if i == 'L':
    L_count += 1
    if (W_count >= 11 or L_count >= 11) and (abs(W_count - L_count) > 1):
    print(str(W_count) + ':' + str(L_count))
    W_count = 0
    L_count = 0
    print()
    W_count = 0
    L_count = 0
    for i in string:
    if i == 'E':
    print(str(W_count) + ':' + str(L_count))
    break
    else:
    if i == 'W':
    W_count += 1
    if i == 'L':
    L_count += 1
    if (W_count >= 21 or L_count >= 21) and (abs(W_count-L_count) > 1):
    print(str(W_count) + ':' + str(L_count))
    W_count = 0
    L_count = 0

    • @ 2018-08-25 21:01:51

      python 没缩进!!! game over

  • -1
    @ 2017-11-11 13:56:41
    #include <stdio.h>
    #include <stdlib.h>
    #include <limits.h>
    #define MAXLEN 100000
    int main()
    {
        char ch;
        int ele[MAXLEN][2], twel[MAXLEN][2];
        int a = 0, b = 0;
        while ((ch = getchar()) != 'E') {
            if (ch == '\n' || ch == ' ')
                continue;
            ele[a][ch=='L']++;
            twel[b][ch=='L']++;
            if ((ele[a][0] >= 11 || ele[a][1] >= 11)
                    && abs(ele[a][0]-ele[a][1]) >= 2)
                a++;
            if ((twel[b][0] >= 21 || twel[b][1] >= 21)
                    && abs(twel[b][0]-twel[b][1]) >= 2)
                b++;
        }
        for (int i = 0; i <= a; i++) {
            printf("%d:%d\n", ele[i][0], ele[i][1]);
        }
        printf("\n");
        for (int j = 0; j <= b; j++) {
            printf("%d:%d\n", twel[j][0], twel[j][1]);
        }
        return 0;
    }
    
  • -1
    @ 2006-11-03 20:46:26

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    用最原始的方法做,一直TLE,。。。。搞了半天数组开小了

    开到10000迅速ac

    。。。。。。。。。

    真是BT啊,,浪费我4次提交

  • -1
    @ 2006-10-28 16:01:26

    竟然有0:0的比分!!

    浪费了我3次提交!!

  • -1
    @ 2006-10-28 19:33:17

    楼下的楼下,一直打平不就有148:148嘛

  • -1
    @ 2006-10-27 11:08:04

    第6组 TLE 无语..等待Puppy

  • -1
    @ 2006-11-02 20:42:20

    标准行输出148:148

    有可能么?!

    乒乓球的11分制和21分制都不可能出现一局分数是148:148吧?

    对了,我知道错在哪里了,忘记了乒乓球有deuce制的存在……

  • -1
    @ 2006-10-26 16:19:53

    这题......愚人节做比较好.......耍人用!

  • -1
    @ 2006-11-02 22:52:29

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    ---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

    怕被封号..............程序代码删了..............

  • -1
    @ 2006-10-25 13:16:37

    编译通过...

    ├ 测试数据 01:运行超时|无输出...

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案错误... ├ 标准行输出

     ├ 错误行输出

    ---|---|---|---|---|---|---|---|-

    Unaccepted 有效得分:80 有效耗时:0ms

    这个是怎么回事? 标准行输出怎么会是0:0啊?不可能吧!!再我第一个怎么超时

信息

ID
1217
难度
7
分类
字符串 点击显示
标签
递交数
18768
已通过
4297
通过率
23%
被复制
34
上传者