Here you will find solutions of many problems on spoj. If you want solution of some problem which is not listed in blog or have doubt regarding any spoj problem (which i have solved) or any programming concept (data structure) you can mail me @ raj.nishant360@gmail.com

And my humble request to you all that don't copy the code only try to understand the logic and algorithm behind the code. I have started this because if you tried as hard as you can and still can't find any solution to the problem then you can refer to this.
You can read my answer how to start competitive programming CLICK HERE

Sunday, December 15, 2013

BWIDOW - Black Widow Rings

bwidow spoj black widow ring spoj
Solution to BWIDOW
below given code is for bwidow spoj or black widow ring spoj.
#include
int main()
{
 int t;
 scanf("%d",&t);
 while(t--)
 {
  int N,i,j,count=0,flage=0,index;
  scanf("%d",&N);
  long r[N],R[N];
  for(i=0;iR[j])
      count++;
     else{
      flage=0;
      break;
     }
    }
   }
   if(count==(N-1)){
    flage=1;
    index=i;
    break;
   }
  }
  if(flage==1)
   printf("%d\n",index+1);
  else
   printf("-1\n");
 }
 return 0;
}

No comments:

Post a Comment

Your comment is valuable to us