题解

378 条题解

  • 0
    @ 2017-03-29 21:09:24
    
    #include<iostream>
    #include<string>
    using std::string;
    using std::cout;
    using std::cin;
    using std::endl;
    
    //各分制情况
    void Output(string str, int point);
    
    int main()
    {
        string text;
        std::getline(cin, text, 'E');
    
      //11分制情况
        Output(text, 11);
        cout << endl;
        //21分制情况
        Output(text, 21);
        return 0;
    }
    
    void Output(string str, int point)
    {
        int win = 0, fail = 0;
        for (int i = 0; i<str.length(); i++)
        {
            if (str[i] == 'W')
                win++;
            if (str[i] == 'L')
                fail++;
            if ((win == point && fail < (point - 1)) || (fail == point && win < (point - 1)))
            {
                cout << win << ":" << fail
                    << endl;
                win = 0;
                fail = 0;
            }
            else if ((win == point && fail == (point - 1)) || (fail == point && win == (point - 1)))
                continue;
            else if ((win > point && fail >= (point - 1) && win - fail >= 2) || (fail > point & win >= (point - 1) && fail - win >= 2))
            {
                cout << win << ":" << fail
                    << endl;
                win = 0;
                fail = 0;
            }
        }
        cout << win << ":" << fail;
        cout << endl;
    }
    
    
  • 0
    @ 2017-03-22 21:38:28

    *var
    a:array[0..100000] of char;
    ch:char;
    t,i,x,y:longint;
    begin
    t:=0;
    repeat
    read(ch);
    if (ch='W') or (ch='L') then
    begin
    inc(t);
    a[t]:=ch;
    end;
    until ch='E';//读入:注意数据中有换行
    x:=0;y:=0;
    for i:=1 to t do
    begin
    if a[i]='W' then inc(x);
    if a[i]='L' then inc(y);
    if abs(x-y)>=2 then//分差大于等于2
    if (x>=11) or (y>=11) then
    begin
    writeln(x,':',y);
    x:=0;y:=0;
    end;
    end;
    writeln(x,':',y);//0:0也要输出
    writeln;//11分制
    x:=0;y:=0;
    for i:=1 to t do
    begin
    if a[i]='W' then inc(x);
    if a[i]='L' then inc(y);
    if abs(x-y)>=2 then
    if (x>=21) or (y>=21) then
    begin
    writeln(x,':',y);
    x:=0;y:=0;
    end;
    end;
    writeln(x,':',y);//21分制
    end.

  • 0
    @ 2017-03-14 18:50:32

    var k:char;
    s:ansistring;
    q,p,i,len,l:longint;

    begin
    read(k);
    while k<>'E' do
    begin
    if (k='W')or(k='L') then
    s:=s+k;
    read(k);
    end;
    len:=length(s);
    l:=11;
    for i:=1 to len do
    begin
    if s[i]='W' then inc(q)
    else inc(p);
    if (abs(q-p)>=2)and((q>=l)or(p>=l)) then
    begin
    writeln(q,':',p);
    q:=0;p:=0;
    end;
    end;
    if (q<>0)or(p<>0) then
    writeln(q,':',p);
    l:=21;
    writeln;
    q:=0;p:=0;
    for i:=1 to len do
    begin
    if s[i]='W' then inc(q)
    else inc(p);
    if (abs(q-p)>=2)and((q>=l)or(p>=l)) then
    begin
    writeln(q,':',p);
    q:=0;p:=0;
    end;
    end;
    if (q<>0)or(p<>0) then
    writeln(q,':',p);
    end.
    为什么1,10点爆why

  • 0
    @ 2017-02-21 22:08:37

    字符串很大,一开始开10000,结果re。
    原理很简单,逐一读取,设置两个变量分别累加,直到变量差距>=2并且有一个达到11或21
    ```c++
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    using namespace std;
    int a,b;

    void init(void)
    {
    a = 0;
    b = 0;
    }

    int finish(int a,int b,int x)
    {
    if(abs(a - b) >= 2){
    if(a >= x || b >= x)
    return 1;
    }
    return 0;
    }
    int main(void)
    {
    char s[100000] = {0},str;
    int i = 0;
    while((s[i++] = getchar()) != 'E') ;
    i = 0;
    while((str = s[i++]) != 'E'){
    if(str == 'W'){
    a++;
    }
    else if(str == 'L'){
    b++;
    }

    if(finish(a,b,11)){
    printf("%d:%d\n",a,b);
    init();
    }
    }
    i = 0;printf("%d:%d\n\n",a,b);init();
    while((str = s[i++]) != 'E'){
    if(str == 'W'){
    a++;
    }
    else if(str == 'L'){
    b++;
    }

    if(finish(a,b,21)){
    printf("%d:%d\n",a,b);
    init();
    }
    }
    printf("%d:%d\n",a,b);
    //main();
    return 0;
    }
    ```

  • 0
    @ 2017-02-20 16:30:55

    一开始开了一个10000的数组结果炸RE了,晕死

    #include<iostream>
    #include<stdio.h>
    using namespace std;
    char b[100000]={0};
    int main(void)
    {
        int count1=0,count2=0,now=0;
        char a;
        while((a=getchar())!='E')
        {
            if(a=='L'||a=='W')
                b[now++]=a;     
        }
        for(int i=0;i<now;i++)
        {
            if(b[i]=='W')
                count1++;
            else count2++;
            if((count1==11&&count2<=9)||(count2==11&&count1<=9))
            {
                cout<<count1<<':'<<count2<<'\n';
                count1=0;
                count2=0;
                continue;
            }
            else if((count1>=11&&count2>=10)||(count2>=11&&count1>=10))
            {
                if(count1-count2>=2||count1-count2<=-2)
                {
                    cout<<count1<<':'<<count2<<'\n';
                    count1=0;
                    count2=0;
                    continue;
                }
            }
        }
        cout<<count1<<':'<<count2<<'\n'<<'\n';
        count1=0;count2=0;
        for(int i=0;i<now;i++)
        {
            if(b[i]=='W')
                count1++;
            else count2++;
            if((count1==21&&count2<=19)||(count2==21&&count1<=19))
            {
                cout<<count1<<':'<<count2<<'\n';
                count1=0;
                count2=0;
                continue;
            }
            else if((count1>=21&&count2>=20)||(count2>=21&&count1>=20))
            {
                if(count1-count2>=2||count1-count2<=-2)
                {
                    cout<<count1<<':'<<count2<<'\n';
                    count1=0;
                    count2=0;
                    continue;
                }
            }
        }
        cout<<count1<<':'<<count2<<endl;
    }
    
  • 0
    @ 2017-02-08 16:02:46
    #include<iostream>
    #include<cstring>
    #include<cmath>
    using namespace std;
    char c[50000] = {};
    int score1 = 0, score2 = 0;// w score1 + 1分,l相反
    void f(int x, int y, int prescore1, int prescore2, int mod)// 计算x~y11分赛制下的情形,
    {
        if (c[y] == 'E')
        {
            cout << prescore1 << ':' << prescore2 << endl;
            score1 = score2 = 0;
            return;
        }
        if (c[y] == 'W')
        {
            score1 = prescore1 + 1;
            score2 = prescore2;
        }
        if (c[y] == 'L')
        {
            score1 = prescore1;
            score2 = prescore2 + 1;
        }
        if (c[y] == ' ')
        {
            score1 = score2 = 0;
            f(x, y + 1, prescore1, prescore2, mod);
        }
        if (c[y] == '\n')
        {
            score1 = score2 = 0;
            f(x, y + 1, prescore1, prescore2, mod);
        }
        bool a1, a2, a3, a4, a5;
        a1 = (score1 == mod) && ((score1 - score2) > 1);
        a2 = (score2 == mod) && ((score2 - score1) > 1);
        a3 = (score1 >= mod) && (score2 >= mod) && (abs(score1 - score2) > 1);
        a4 = (score1 == (mod + 1)) && (score2 == (mod - 1));
        a5 = (score1 == (mod - 1)) && (score2 == (mod + 1));
        if (a1 || a2 || a3 || a4 || a5)
        {
            cout << score1 << ':' << score2 << endl;
            score1 = score2 = 0;
            f(y + 1, y + 1, 0, 0, mod);
            return;
        }
        int temp1 = score1, temp2 = score2;
        score1 = score2 = 0;
        f(x, y + 1, temp1, temp2, mod);
        return;
    }
    
    int main()
    {
        char temp;
        int i = 0;
        while (cin >> temp)
        {
            if (temp == 'E')
            {
                c[i++] = temp;
                break;
            }
            c[i++] = temp;
                
        }
        //cout << c;
        f(0, 0, 0, 0, 11);
        cout << endl;
        f(0, 0, 0, 0, 21);
        system("pause");
        return 0;
    }
    
  • 0
    @ 2017-02-08 15:56:15
    #include<iostream>
    #include<cstring>
    #include<cmath>
    using namespace std;
    char c[50000] = {};
    int score1 = 0, score2 = 0;// w score1 + 1分,l相反
    void f11(int x, int y, int prescore1, int prescore2)// 计算x~y11分赛制下的情形,
    {
        if (c[y] == 'E')
        {
            cout << prescore1 << ':' << prescore2 << endl;
            score1 = score2 = 0;
            return;
        }
        if (c[y] == 'W')
        {
            score1 = prescore1 + 1;
            score2 = prescore2;
        }
        if (c[y] == 'L')
        {
            score1 = prescore1;
            score2 = prescore2 + 1;
        }
        if (c[y] == ' ')
        {
            score1 = score2 = 0;
            f11(x, y + 1, prescore1, prescore2);
        }
        if (c[y] == '\n')
        {
            score1 = score2 = 0;
            f11(x, y + 1, prescore1, prescore2);
        }
        bool a1, a2, a3, a4, a5;
        a1 = (score1 == 11) && ((score1 - score2) > 1);
        a2 = (score2 == 11) && ((score2 - score1) > 1);
        a3 = (score1 >= 11) && (score2 >= 11) && (abs(score1 - score2) > 1);
        a4 = (score1 == 12) && (score2 == 10);
        a5 = (score1 == 10) && (score2 == 12);
        if (a1 || a2 || a3 || a4 || a5)
        {
            cout << score1 << ':' << score2 << endl;
            score1 = score2 = 0;
            f11(y + 1, y + 1, 0, 0);
            return;
        }
        int temp1 = score1, temp2 = score2;
        score1 = score2 = 0;
        f11(x, y + 1, temp1, temp2);
        return;
    }
    void f21(int x, int y, int prescore1, int prescore2)// 计算x~y11分赛制下的情形,
    {
        if (c[y] == 'E')
        {
            cout << prescore1 << ':' << prescore2 << endl;
            return;
        }
        if (c[y] == 'W')
        {
            score1 = prescore1 + 1;
            score2 = prescore2;
        }
        if (c[y] == 'L')
        {
            score1 = prescore1;
            score2 = prescore2 + 1;
        }
        if (c[y] == ' ')
        {
            score1 = score2 = 0;
            f21(x, y + 1, prescore1, prescore2);
        }
        if (c[y] == '\n')
        {
            score1 = score2 = 0;
            f21(x, y + 1, prescore1, prescore2);
        }
        bool a1, a2, a3, a4, a5;
        a1 = (score1 == 21) && ((score1 - score2) > 1);
        a2 = (score2 == 21) && ((score2 - score1) > 1);
        a3 = (score1 >= 21) && (score2 >= 21) && (abs(score1 - score2) > 1);
        a4 = (score1 == 22) && (score2 == 20);
        a5 = (score1 == 20) && (score2 == 22);
        if (a1 || a2 || a3 || a4 || a5)
        {
            cout << score1 << ':' << score2 << endl;
            score1 = score2 = 0;
            f21(y + 1, y + 1, 0, 0);
            return;
        }
        int temp1 = score1, temp2 = score2;
        score1 = score2 = 0;
        f21(x, y + 1, temp1, temp2);
        return;
    }
    int main()
    {
        char temp;
        int i = 0;
        while (cin >> temp)
        {
            if (temp == 'E')
            {
                c[i++] = temp;
                break;
            }
            c[i++] = temp;
                
        }
        //cout << c;
        f11(0, 0, 0, 0);
        cout << endl;
        f21(0, 0, 0, 0);
        system("pause");
        return 0;
    }
    
  • 0
    @ 2017-01-19 22:02:10

    C++题解
    vector不定长数组都知道吧,不知道请自习STL
    顺便自习一下register,限于篇幅,不再累述

    评测结果
    编译成功

    foo.cpp: In function 'int main()':
    foo.cpp:37:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(reg int i=0;i<a[0].size();i++)
    ~^~~~~~~~~~~~
    foo.cpp:40:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(reg int i=0;i<b[0].size();i++)
    ~^~~~~~~~~~~~
    测试数据 #0: Accepted, time = 0 ms, mem = 736 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 748 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 748 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 748 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 752 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 868 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 780 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 732 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 736 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 736 KiB, score = 10
    Accepted, time = 0 ms, mem = 868 KiB, score = 100

    代码如下:

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<vector>
    #include<algorithm>
    using namespace std;
    #define reg register
    char ch;
    vector<int>a[2],b[2];
    int w0=0,w1=0,l0=0,l1=0;
    int main()
    {
    while(1)
    {
    ch=getchar();
    reg int flag1=0,flag2=0;
    if(ch=='\n') ch=getchar();
    if(ch=='W') w0++,w1++;
    else
    if(ch=='L')
    l0++,l1++;
    else if(ch=='E')
    {
    a[0].push_back(w0),a[1].push_back(l0);
    b[0].push_back(w1),b[1].push_back(l1);
    break;
    }
    if(abs(w0-l0)>=2&&(w0>=11||l0>=11))
    a[0].push_back(w0),a[1].push_back(l0),flag1=1;
    if(abs(w1-l1)>=2&&(w1>=21||l1>=21))
    b[0].push_back(w1),b[1].push_back(l1),flag2=1;
    if(flag1) w0=0,l0=0;
    if(flag2) w1=0,l1=0;
    }
    if(b[0].size()==0)
    puts("0:0"),puts("0:0");
    for(reg int i=0;i<a[0].size();i++)
    printf("%d:%d\n",a[0][i],a[1][i]);
    putchar('\n');
    for(reg int i=0;i<b[0].size();i++)
    printf("%d:%d\n",b[0][i],b[1][i]);
    return 0;
    }

  • 0
    @ 2017-01-19 12:30:49

    Var
    i,d,j,j1,w,w1,l,l1:longint;
    a,b,a1,b1:array[1..100000]of integer;
    k:char;
    Begin
    d:=1; read(k);
    while k<>'E' do
    begin
    if k='W' then
    begin
    inc(w); inc(w1);
    end;
    if k='L' then
    begin
    inc(l); inc(l1);
    end;
    if (w>=11) or (l>=11) then
    if (w-l>=2) or (l-w>=2) then
    begin
    inc(j);
    a[j]:=w;
    b[j]:=l;
    w:=0; l:=0;
    end;
    if (w1>=21) or (l1>=21) then
    if (w1-l1>=2) or (l1-w1>=2) then
    begin
    inc(j1);
    a1[j1]:=w1;
    b1[j1]:=l1;
    w1:=0; l1:=0;
    end;
    inc(d);
    if d mod 20=0 then
    readln(k)
    else
    read(k);
    end;
    for i:=1 to j do
    writeln(a[i],':',b[i]);
    writeln(w,':',l);
    writeln;
    for i:=1 to j1 do
    writeln(a1[i],':',b1[i]);
    writeln(w1,':',l1);
    readln;
    End.

    贼他妈 恶心 ,数组 要开到很大 才给我 过,可怜我提交了5次。

  • 0
    @ 2017-01-17 10:45:57

    注意0:0的输出

  • 0
    @ 2016-11-28 05:47:07
    #include <iostream>
    #include <cstdlib>
    #include <cstdio>
    #include <algorithm>
    #include <cstring>
    #include <vector>
    
    using namespace std;
    
    
    
    int main()
    {
      vector<char> s;
      char ch;
      while(ch!='E')
      {
        ch=cin.get();
        if(isalpha(ch)){s.push_back(ch);}
      }
    
      vector<char>::iterator iter;
    
    
      int  a=0;
      int  b=0;
      for(iter=s.begin();iter!=s.end();iter++)
      {
        if(*iter=='W'){a++;}
        if(*iter=='L'){b++;}
        if((a>=11 || b>=11)&&(abs(a-b)>=2)){printf("%d:%d\n",a,b);a=b=0;}
      }
      cout<<a<<':'<<b<<endl<<endl;
      
    
      
      a=0;b=0;
      for(iter=s.begin();iter!=s.end();iter++)
      {
        if(*iter=='W'){a++;}
        if(*iter=='L'){b++;}
        if((a>=21 || b>=21)&&(abs(a-b)>=2)){printf("%d:%d\n",a,b);a=b=0;}
      }
      cout<<a<<':'<<b<<endl;
    
    
      return 0;
    }
    
  • 0
    @ 2016-11-16 09:32:58

    #include<iostream>
    #include<cstdio>
    #include<cctype>
    #include<cmath>
    using namespace std;
    char cc;
    int a1[10000],b1[10000];

    int a2[10000],b2[10000];

    int Abs(int num)
    {
    if(num<0)
    return 0-num;
    return num;
    }
    int main()
    {
    int i=0;
    int j=0;
    while(1)
    {
    cc= getchar();
    if(cc=='E')
    break;
    if(!isalpha(cc))
    continue;
    if(cc=='W')
    a1[i]++,a2[j]++;
    if(cc=='L')
    b1[i]++,b2[j]++;
    if(a1[i]>=11 || b1[i]>=11)
    if(Abs(a1[i]-b1[i])>=2)
    i++;
    if(a2[j]>=21 || b2[j]>=21)
    if(Abs(a2[j]-b2[j])>=2)
    j++;
    }
    for(int k=0;k<=i;k++)

    cout<<a1[k]<<':'<<b1[k]<<endl;
    cout<<endl;
    for(int k=0;k<=j;k++)
    cout<<a2[k]<<':'<<b2[k]<<endl;
    return 0;
    }

  • 0
    @ 2016-11-15 19:02:35
    var
      ch:char;
      a,a1,b,b1:array[1..100000] of integer;
      i,j,k:integer;
    begin
      i:=1;
      j:=1;
      repeat
        read(ch);
        if ch = 'W' then
          begin
            inc(a[i]);
            inc(b[j]);
          end;
        if ch = 'L' then
          begin
            inc(a1[i]);
            inc(b1[j]);
          end;
        if ((a[i] >= 11) or (a1[i] >= 11)) and (abs(a[i]-a1[i]) >=2) then
          inc(i);
        if ((b[j] >= 21) or (b1[j] >= 21)) and (abs(b[j]-b1[j]) >=2) then
          inc(j);
      until ch = 'E';
      for k:=1 to i do
        writeln(a[k],':',a1[k]);
      writeln;
      for k:=1 to j do
        writeln(b[k],':',b1[k]);
    end.
    
  • 0
    @ 2016-11-09 12:58:29

    #include<bits/stdc++.h>
    using namespace std;
    char a[1000000];
    int main()
    {
    int i,j,k,l=0,n,m,w=0;
    for(i=0;a[i-1]!='E';i++) cin>>a[i];
    n=strlen(a);
    if(a[0]=='E') cout<<"0:0\n\n0:0";
    for(i=0;i<n;i++){
    if(a[i]=='W') w++;
    if(w>=11&&w-l>=2){
    cout<<w<<":"<<l<<endl;
    w=0;
    l=0;
    }
    if(a[i]=='L') l++;
    if(l>=11&&l-w>=2){
    cout<<w<<":"<<l<<endl;
    w=0;
    l=0;
    }
    if(a[i]=='E'){
    cout<<w<<":"<<l<<endl;
    w=0;
    l=0;
    break;
    }
    }
    cout<<endl;
    for(i=0;i<n;i++){
    if(a[i]=='W') w++;
    if(w>=21&&w-l>=2){
    cout<<w<<":"<<l<<endl;
    w=0;
    l=0;
    }
    if(a[i]=='L') l++;
    if(l>=21&&l-w>=2){
    cout<<w<<":"<<l<<endl;
    w=0;
    l=0;
    }
    if(a[i]=='E'){
    cout<<w<<":"<<l<<endl;
    w=0;
    l=0;
    break;
    }
    }
    return 0;
    }

  • 0
    @ 2016-11-09 12:46:02

    #include <bits/stdc++.h>
    using namespace std;
    char t[1000005];
    int main()
    {
    int i,j,k,l,n=0,m=0,a=0;
    for(i=0;t[i-1]!='E';i++) cin>>t[i];

    for(i=0;;i++) {
    if(t[i]=='E') break;
    else if(t[i]=='W') n++;
    else m++;
    if((n>=11&&n-m>=2) || (m>=11&&m-n>=2)) {
    cout<<n<<":"<<m<<endl;
    n=m=0;
    }
    }
    cout<<n<<":"<<m<<endl;
    n=m=0;
    cout<<endl;

    for(i=0;;i++) {
    if(t[i]=='E') break;
    else if(t[i]=='W') n++;
    else m++;
    if((n>=21&&n-m>=2) || (m>=21&&m-n>=2)) {
    cout<<n<<":"<<m<<endl;
    n=m=0;
    }
    }
    cout<<n<<":"<<m<<endl;
    if(i=0) {
    cout<<"0:0\n\n0:0"<<endl;
    return 0;
    }
    return 0;
    }

  • 0
    @ 2016-11-08 21:06:47

    pascal代码,数组随便定的哈哈,而且比较烦,比不过楼上的大神,不过比较容易理解,可以看一下。
    pascal
    var
    i,j,hua,dui:longint;
    n:char;
    a:array[1..500000] of char;
    begin
    read(n); i:=1;
    while n<>'E' do begin
    if n='W' then begin a[i]:='W'; i:=i+1; end;
    if n='L' then begin a[i]:='L'; i:=i+1; end;
    read(n);
    end;
    i:=i-1;
    for j:=1 to i do
    begin
    if a[j]='W' then hua:=hua+1;
    if a[j]='L' then dui:=dui+1;
    if (abs(hua-dui)>=2) and ((hua>=11) or(dui>=11)) then begin
    writeln(hua,':',dui);
    hua:=0; dui:=0;
    end;
    end;
    writeln(hua,':',dui);
    writeln;
    hua:=0; dui:=0;
    for j:=1 to i do
    begin
    if a[j]='W' then hua:=hua+1;
    if a[j]='L' then dui:=dui+1;
    if (abs(hua-dui)>=2) and ((hua>=21) or(dui>=21)) then begin
    writeln(hua,':',dui);
    hua:=0; dui:=0;
    end;
    end;
    writeln(hua,':',dui);
    end.

  • 0
    @ 2016-11-06 11:37:31

    #include <bits/stdc++.h>
    using namespace std;
    char s[100000];
    int main(){
    char c;

    int a = 0, b = 0, d = 0, e = 0;
    int win, lose;
    int temp = 0;
    while(scanf("%c", &c) != EOF){
    if (c == 'E')break;
    if (c == 'W'|| c=='L'){
    s[temp] = c;
    temp++;}
    }

    int length = strlen(s);
    for (int i = 0; i < length; i++){
    if (s[i]=='W')a++;
    if (s[i]=='L')b++;
    if (a>=11&&a-b>=2){
    cout << a <<":"<<b<<endl;
    a = 0, b = 0;
    }
    if (b>=11&&b-a>=2){
    cout << a <<":"<<b<<endl;
    a = 0, b = 0;
    }
    }
    cout << a <<":"<<b << endl << endl;
    for (int i = 0; i < length; i++){
    if (s[i]=='W')d++;
    if (s[i]=='L')e++;
    if (d>=21&&d-e>=2){
    cout << d <<":"<<e<<endl;
    d = 0, e = 0;
    }
    if (e>=21&&e-d>=2){
    cout << d <<":"<<e<<endl;
    d = 0, e = 0;
    }
    }
    cout << d <<":"<<e<< endl;
    return 0;
    }

  • 0
    @ 2016-10-27 19:59:08

    测试数据 #0: Accepted, time = 0 ms, mem = 556 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 556 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 560 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 564 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 564 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 740 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 588 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 556 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 556 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 556 KiB, score = 10
    Accepted, time = 0 ms, mem = 740 KiB, score = 100
    啊哈,好坑啊QAQ
    浪费我几分钟。。。。。。

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <vector>
    #include <algorithm>
    using namespace std;
    char ch;
    vector<int> a[2],b[2];
    int w0 = 0,w1 = 0,l0 = 0,l1 = 0; 
    int main() {
        while (1) {
            scanf("%c",&ch);
            int flag1 = 0,flag2 = 0;
            if ( ch == '\n' ) ch = getchar();
            if ( ch == 'W' ) w0 ++,w1 ++;
            else if ( ch == 'L' ) l0++,l1++;
            else if ( ch == 'E' ) {
                a[0].push_back(w0),a[1].push_back(l0);
                b[0].push_back(w1),b[1].push_back(l1);
                break;
            }
            if ( abs(w0-l0) >= 2 && ( w0 >= 11 || l0 >= 11 ) )
                a[0].push_back(w0),a[1].push_back(l0),flag1 = 1;
            if ( abs(w1-l1) >= 2 && ( w1 >= 21 || l1 >= 21 ) )
                b[0].push_back(w1),b[1].push_back(l1),flag2 = 1;
            if ( flag1 ) w0 = 0,l0 = 0;
            if ( flag2 ) w1 = 0,l1 = 0;
        }
        if ( b[0].size() == 0 ) printf("0:0\n0:0");
        for (int i=0;i<a[0].size();i++)
            printf("%d:%d\n",a[0][i],a[1][i]);
        putchar('\n');
        for (int i=0;i<b[0].size();i++)
            printf("%d:%d\n",b[0][i],b[1][i]);
        return 0;
    }
    
  • 0
    @ 2016-10-20 19:18:13
    //#include<fstream>
    #include<iostream> 
    #include<string>
    #include<cmath>
    using namespace std;
    string s;
    //ifstream cin("test.in");
    //ofstream cout("test.out");
    void solve(int fen){
        int x=0,y=0,len=s.size();
        for(int i=0;i<len;i++){
            if(s[i]=='E')break;
            if(s[i]=='W')x++;
            if(s[i]=='L')y++;
            if((x>=fen||y>=fen)&&abs(x-y)>1){
                cout<<x<<':'<<y<<endl;
                x=y=0;
            }
        }
        cout<<x<<':'<<y<<endl;
        
    } 
    int main(){
        string t;
        while(getline(cin,t))s+=t;
        solve(11);
        cout<<endl;
        solve(21);
        return 0;
    }
    
  • 0
    @ 2016-09-23 18:34:44
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    
    int  cun[99999];
    int jishu;
    int l,r,tem=0;
    char q;
    int main()
    {int temp=0;
        while(cin>>q)
        {if(q=='E')break;
        else 
        {temp++;
        if(q=='W')
        {cun[temp]=cun[temp-1]+1;}
        else
       { cun[temp]=cun[temp-1];}}
    }
    if(temp==0)
    {cout<<"0:0"<<endl<<endl;
    cout<<"0:0";}
    else{
      for(int i=1;i<=temp;i++)
      if(abs(2*cun[i]-2*cun[tem]-i+tem)>=2&&i-tem>=11&&(cun[i]-cun[tem]>=11||(i-tem)-(cun[i]-cun[tem])>=11))
      {cout<<cun[i]-cun[tem]<<":"<<i-tem-cun[i]+cun[tem]<<endl;
      tem=i;}
      cout<<cun[temp]-cun[tem]<<":"<<temp-tem-cun[temp]+cun[tem]<<endl;
      tem=0;
      cout<<endl;
     for(int i=1;i<=temp;i++)
      if(abs(2*cun[i]-2*cun[tem]-i+tem)>=2&&i-tem>=21&&(cun[i]-cun[tem]>=21||(i-tem)-(cun[i]-cun[tem])>=21))
      {cout<<cun[i]-cun[tem]<<":"<<i-tem-cun[i]+cun[tem]<<endl;
      tem=i;}
      cout<<cun[temp]-cun[tem]<<":"<<temp-tem-cun[temp]+cun[tem]<<endl;
    // system("pause");
    }
        
     
       
     
        return 0;
    }
    

信息

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