# Can anyone help me in finding the bug/bugs?

I tried almost 4 hours trying to find the bugs in my solution to the problem -[SPOJ Problem][1].

It is a simple Lazy-Propagation Sum Queries problem.

Here’s my Code -

``````
[2]

[1]: http://www.spoj.com/problems/HORRIBLE/
[2]: http://ideone.com/f4i5Aw``````

You can have a look at my solution. http://ideone.com/bDQWWm

If you have any doubts, you can ask in the comment section below.

Hi, prrateekk

here is your accepted code with correction as comment http://ideone.com/XtrJIY

1 Like

Can any of you please say what’s wrong with this following code? Here it’s showing runtime error, but in my compiler there is no issue.

#include <stdio.h>
#include <stdlib.h>
void check(int,int);

int a[50],b[10],c[10],t,m,n,i,temp,count=0,j=0,p;
int main()
{
scanf("%d",&t);
while(j<t)
{
scanf("%d%d",&n,&m);
b[j]=n;
c[j]=m;
j++;
}
j=0;
while(j<t)
{
count=0;
check(b[j],c[j]);
j++;
}
return 0;
}

void check(int n,int m)
{
for(i=1;i<=n;i++)
{
a[i]=i;
a[n+i]=i;
}
temp=m+1;
for(i=1;i<=n+m;i++)
{
if(a[temp]!=0)
{
p=a[temp];
a[temp]=0;
temp=p+m;
}
else
{
break;
}
count++;
}
if(count==n)
printf("\nYES\n");
else
{
printf("\nNO %d\n",(n-count));
}
return;
}

this correction is made in that code which you have posted in comment of Horrible query question asked by @artist 3 hours ago i have also posted your code there

do not paste code like story simply give link to ideone etc.

its ok runtime depend on input data also thats why it work on your machine but not in codechef.