第9个点迷之错误求解

编译成功

测试数据 #0: Accepted, time = 0 ms, mem = 1480 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 1480 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 1480 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 1480 KiB, score = 10
测试数据 #4: Accepted, time = 15 ms, mem = 1480 KiB, score = 10
测试数据 #5: Accepted, time = 15 ms, mem = 1484 KiB, score = 10
测试数据 #6: Accepted, time = 15 ms, mem = 1480 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 1484 KiB, score = 10
测试数据 #8: WrongAnswer, time = 15 ms, mem = 1480 KiB, score = 0
测试数据 #9: Accepted, time = 0 ms, mem = 1480 KiB, score = 10
WrongAnswer, time = 60 ms, mem = 1484 KiB, score = 90

代码如下:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
char s[999999];
int main()
{
char t;
int i=0;
while(1)
{
scanf("%c",&t);
if(t=='E')
break;
else
{
s[i]=t;
i++;
}
}
int sh=0,sc=0;
int len=strlen(s);
for(i=0;i<len;i++)
{
if(s[i]=='W')
sh++;
else if(s[i]=='L')
sc++;
if((sh>=11||sc>=11)&&abs(sh-sc)>=2)
{
printf("%d:%d\n",sh,sc);
sh=0;
sc=0;
}
}
if(sh==0&&sc==0)
printf("0:0\n");
else if(sh<11&&sc<11)
printf("%d:%d\n",sh,sc);
sh=0;
sc=0;
printf("\n");
for(i=0;i<len;i++)
{
if(s[i]=='W')
sh++;
else if(s[i]=='L')
sc++;
if((sh>=21||sc>=21)&&abs(sh-sc)>=2)
{
printf("%d:%d\n",sh,sc);
sh=0;
sc=0;
}
}
if(sh==0&&sc==0)
printf("0:0");
else if(sh<21&&sc<21)
printf("%d:%d",sh,sc);
return 0;
}
不懂为什么就一个点错了,求解

8 条评论

  • @ 2016-08-21 18:54:26

    更正的代码放上面了= =

  • @ 2016-08-21 18:53:45
    #include<stdio.h>
    #include<string.h>
    #include<stdlib.h>
    #include<math.h>
    char s[100001];
    int main()
    {
        char t;
        int i=0;
        while(1)
        {
            scanf("%c",&t);
            if(t=='E')
            break;
            else
            {
                s[i]=t;
                i++;
            }
        }
        int sh=0,sc=0;
        int len=strlen(s);
        for(i=0;i<len;i++)
        {
            if(s[i]=='W')
            sh++;
            else if(s[i]=='L')
            sc++;
            if((sh>=11||sc>=11)&&abs(sh-sc)>=2)
            {
                printf("%d:%d\n",sh,sc);
                sh=0;
                sc=0;
            }
        }
        printf("%d:%d\n",sh,sc);
        sh=0;
        sc=0;
        printf("\n");
        for(i=0;i<len;i++)
        {
            if(s[i]=='W')
            sh++;
            else if(s[i]=='L')
            sc++;
            if((sh>=21||sc>=21)&&abs(sh-sc)>=2)
            {
                printf("%d:%d\n",sh,sc);
                sh=0;
                sc=0;
            }
        }
        printf("%d:%d",sh,sc);
        return 0;
    }
    
  • @ 2016-08-21 18:44:55

    问题解决了= =
    我这个代码如果一场比赛一直没有结束(从开始输出一直到结束输出一直没有分出胜负)就不会输出了
    真心诡异

  • @ 2016-08-21 13:37:17
    // You can try this data
    
    ==input:
    WLWLWLWLWLWLWLWLWLWL
    WLWLWLWLWLWLWLWLWLWL
    WLWLWLWLWLWLWLWLWLWL
    WLWLWLWLWLWLWLWLWLWL
    WLWLWLWLWLWLWLWLWLWL
    WLWLWLWLWLWLWLWLWLWL
    WLWLWLWLWLWLWLWLWLWL
    WLWLWLWLWLWLWLWLWLWL
    WLWLWLWLWLWLWLWLWLWL
    WLWLWLWLWLWLWLWLWLWL
    WLWLWLWLWLWLWLWLWLWL
    WLWLWLWLWLWLWLWLWLWL
    WLWLWLWLWLWLWLWLWLWL
    WLWLWLWLWLWLWLWLWLWL
    WLWLWLWLWLWLWLWLE
    
    ==ans:
    148:148
    148:148
    
  • @ 2016-07-15 14:29:24

    如果WWWWWWWWWWW这组对了你就对了
    答案是
    11:0
    0:0

    11:0

    • @ 2016-08-20 18:00:50

      我这一组的答案确实是这样的啊,从我的代码里可以看到我讨论了新开一局的情况啊

  • @ 2016-07-13 08:50:12

    注意如果刚好结束的话要开始新的一局,分数是0:0

  • @ 2016-07-13 08:50:11

    注意如果刚好结束的话要开始新的一局,分数是0:0

  • @ 2016-06-30 19:47:47

    顺便求第9个点的数据

  • 1

信息

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