[algogeeks] spoj problem

2012-01-23 Thread D!leep Gupta
guys plz help...
http://www.spoj.pl/problems/BUGLIFE/

i m getting wrong ans can any one give me the test case on which my code
giving wrong... i m unable to find out

#include#define MAX 2500int front=-1;int rear=-1;int q[MAX];
 void addq(int n)
{
q[++rear]=n;
}int delq()
{
if(front==rear)
return -1;
else
return q[++front];
}
 int main(){int t,k=0;int num,action,m,n;int i,j;scanf
("%d",&t);while(t--)
{
k++;
front=-1;
rear=-1;
int error=0;
int visit[MAX]={0};
visit[0]=1;
scanf 
("%d%d",&num,&action);
int n=num;
int arr[num][num],a[num];
for(i=0;ihttp://www.opengroup.org/onlinepubs/009695399/functions/scanf.html>("%d%d",&m,&n);
arr[m-1][n-1]=arr[n-1][m-1]=1;
}
int l;
addq(0);
while(n--)
{

if((i=delq())==-1)
{for(l=0;lhttp://www.opengroup.org/onlinepubs/009695399/functions/printf.html>("Scenario
#%d\n",k);
if(error)
printf
("Suspicious
bugs found!\n");
elseprintf
("No
suspicious bugs found!\n");
}return 0;}


-- 
Dileep Kumar
3rd year
Computer Science & Engineering
NIT, Allahabad

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] apti

2011-08-20 Thread D!leep Gupta
60mph

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] MS test

2011-08-08 Thread D!leep Gupta
yup 1st ans is b.

On Sat, Aug 6, 2011 at 10:12 PM, sukran dhawan wrote:

> i think 1st one is b.not sure. can anybody correct me?
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Dileep Kumar
Computer Science & Engineering
NIT, Allahabad

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: Re: [algogeeks] aptitude

2011-08-03 Thread D!leep Gupta
Let the number on mile stone 1 be XY, so on next milestone number will be
YX.
Now if we see the numbers again then it is possible only when mile stone 3
contains a 3 digit number.
Also, from above points it is clear that YX is greater than XY and X!=0 and
Y!=0 and Y>X, and the next number is the number starting from 1.

So, now the possible 3 digit values are 1XY or 1YX or 1AX or 1AY or 1YA or
1XA where A is another variable of single digit.
In first 2 cases(1XY,1YX) we will get Y-X is a fraction so it's not valid
assumption.
Now, in other cases as 1AX or 1XA, on solving X is coming negative so it is
again a false assumption.
In case of 1YA we get an equation in which minimum possible value of Y comes
to be as 12, which is again not accepted.
Finally in 1AY on solving equation comes which satisfies for A=0 and Y=6.
Thus our answer comes as X=1,Y=6,A=0.

So ans is 16,61,106.

This is just for explaining the logic behind this problem. For fast
calculation use hit and trial (1Y,Y1,10Y).

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: latest google interview questions

2011-08-03 Thread D!leep Gupta
@Admin: yup, Plz ban such type of users from this group.

Dileep Kumar
Computer Science & Engineering

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Puzzle[Google] Can be Solved programatically as well

2011-07-19 Thread D!leep Gupta
Ans. *German*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: spoj shlights

2011-06-28 Thread D!leep Gupta
@vaibhav :acc. to u Its giving 9 for "BGBBGGGBBBGBGB" bt it should be 8
how?
my code:
#include
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int i=0,s=0,count=0,c=0,flag=1;
char a[15],ch;
scanf("%s",a);
while(a[i]!='\0')
{   if(flag) while(a[i]=='B') {i++; flag=0;}  //except heading
'B'
while(a[i]=='G')
{count++; i++;}
s+=(count-1);
count=0;
while(a[i]=='B')
{c++; i++;}
s+=c;
c=0;

}
printf("%d\n",s);
}
return 0;
}

On Tue, Jun 28, 2011 at 12:50 AM, vaibhav agarwal <
vibhu.bitspil...@gmail.com> wrote:

> @kartik also consider the case of  GB the answer is 1 BG. ie
> trailing G's left.
> BGB leading B's left hence only one G followed by B therefore only one
> iteration.
>
> try out some cases u will find hw it wrks.
>
>
> On Tue, Jun 28, 2011 at 12:42 AM, vaibhav agarwal <
> vibhu.bitspil...@gmail.com> wrote:
>
>> @kartik
>>
>> yup frgt to mention the last case 1 followed by zero's in that case number
>> of iterations is the no. of trailing zeroes.
>> GBGBBB
>> will have four iterations
>> 101000 = 1(one zero b/w two ones) + 3(last 1 followed by 3 zero's)
>>
>> BGBGBB,BBGBGB,BBBGBG,GG
>>
>> well logic is how hw mny jump of 1's u need to do to get it to the end of
>> the sequence.
>> GBG requires 1 iteration ie BGG
>>
>>
>> On Mon, Jun 27, 2011 at 11:27 PM, kartik sachan 
>> wrote:
>>
>>> HEY DUDE I AM NOT GETTING UR LOGIC AT ALL I THINK HOW U WILL SATISFY THIS
>>> CASE GBGBBB
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Dileep Kumar
Computer Science & Engineering
NIT, Allahabad

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] without sizeof

2011-06-23 Thread D!leep Gupta
#include
main()
{
long double *var;
printf("%d",(char*)(var+1)-(char*)var);
return 0;
}

This also may be the solution... by taking the pointer of that variable...

On Fri, Jun 24, 2011 at 2:09 AM, vaibhav shukla wrote:

> here is the generalized way
>
>
> #include
> #define SIZEOF(var) (size_t)(&var+1) - (size_t)(&var)
> main()
> {
> double x;
> printf("The size of x is %d\n",SIZEOF(x));
> return 0;
> }
>
> On Fri, Jun 24, 2011 at 1:35 AM, Anika Jain wrote:
>
>> #include
>>
>> int main()
>> {
>> char x='9',size=0,count;
>> while(x)
>> {
>> x = x<<1;
>> count++;
>> if((count=count%8)==0)
>> {
>> size++;
>> }
>> }
>> printf("%d\n",size);
>> return 0;
>> }
>>
>> this code i tried to find size of a variable without using sizeof.. but
>> its only for ints and chars... not general.. does anybody hava a general
>> answer??
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
>   best wishes!!
> Vaibhav Shukla
> DU-MCA
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Dileep Kumar
B.Tech 3rd Yr
MNNIT, Allahabad

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] c query

2011-06-23 Thread D!leep Gupta
m also getting=>>   google 35000.00

On Fri, Jun 24, 2011 at 1:25 AM, Anika Jain  wrote:

> bt same code on my gcc gives google 35000.00..
>
>
> On Fri, Jun 24, 2011 at 1:02 AM, piyush kapoor wrote:
>
>> http://ideone.com/CJxFK give (null) 0.00
>> --
>> *Regards,*
>> *Piyush Kapoor,*
>> *CSE-IT-BHU*
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Dileep Kumar
B.Tech 3rd Yr
MNNIT, Allahabad

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] [brain teaser ] Life Or Death 3 june

2011-06-03 Thread D!leep Gupta
all white marble in one bowl... all black in other bowl..
On Fri, Jun 3, 2011 at 1:51 PM, Naveen Kumar wrote:

> I think "*mix the bowls around"* will shift layers too.
>
>
> On Fri, Jun 3, 2011 at 1:43 PM, Pragya lal  wrote:
>
>> u r blindfold , so how can u b so sure that u will be choosing bowl having
>> one white marble ? u can choose other bowl also and in that case probability
>> of picking white marble is 1/2.
>>
>> where as in my case it doesnt matter which bowl i choose... i will be
>> picking white marble only even if i am blindfold so in every case higher
>> probability of wining life is there..
>>
>>
>> On Fri, Jun 3, 2011 at 1:35 PM, bhavana  wrote:
>>
>>> there is no concept of top & bottom layer bcoz it is assumed that
>>> probablity of drawing every marble is same.
>>>
>>> Please read my solution carefully...i wrote only 1 white marble in 1
>>> bowl...rest all marbles(i.e. rest white & all black) in the other bowl..
>>>
>>>
>>> On Fri, Jun 3, 2011 at 1:28 PM, Pragya lal  wrote:
>>>
 @bhavana-
  what if u choose bowl full of black marbles when u r blindfold ?? in
 that case u will surely die...
 According to me, i will place all white marbles in top layer of both
 bowls and all black marbles at below layer in both bowl. so that when i am
 blindfold whichever the bowl i will choose i will pickup white marble only,
 since it is on top layer of both the bowl.


 On Fri, Jun 3, 2011 at 12:55 PM, bhavana  wrote:

> 1 white marble in one bowl...rest all marbles in the other bowl..
>
>
> On Fri, Jun 3, 2011 at 12:44 PM, Lavesh Rawat 
> wrote:
>
>> *life or death Puzzle
>>  *
>> *
>> *
>> **
>> *You are a prisoner sentenced to death. The Emperor offers you a
>> chance to live by playing a simple game. He gives you 50 black marbles, 
>> 50
>> white marbles and 2 empty bowls. He then says, 'Divide these 100 marbles
>> into these 2 bowls. You can divide them any way you like as long as you 
>> use
>> all the marbles. Then I will blindfold you and mix the bowls around. You
>> then can choose one bowl and remove ONE marble. If the marble is WHITE 
>> you
>> will live, but if the marble is BLACK... you will die.'
>>
>> How do you divide the marbles up so that you have the greatest
>> probability of choosing a WHITE marble?
>> *
>> *
>> *
>>
>> *Update Your Answers at* : Click 
>> Here
>>
>>
>> Solution:
>> Will be updated after 1 day
>>
>>
>> --
>>
>> "Never explain yourself. Your friends don’t need
>> it and your enemies won’t believe it" .
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

  --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Cheers
> Naveen Kumar
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send e