Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Wrong answer in LEBOMBS

$
0
0
#include<stdio.h>

#include<string.h>

int n,i,t,count;

char s[10056];

int main()

{
    scanf("%d",&t);
    while(t--)
{
    scanf("%d",&n);
    scanf("%s",s);
    getchar();
    count=0;
    for(i=0;i<n;i++)
    {
       if((s[i+1]=='1')&&((i+1)<n))
       {
       i+=2;
       continue;
       }
       if(s[i]=='1')
       {
        i++;
        continue;
       }
       count++; 
    }
    printf("%d\n",count);  
    }
return 0;       
}

`why this code is giving WA ? problem link http://codechef.com/problems/LEBOMBS Give a test case on which it fails.


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>