[algogeeks] simpel DP solution

2011-10-31 Thread mc2 .
Hey guys , I am trying to solve this DP problem : http://community.topcoder.com/stat?c=problem_statement&pm=10033&rd=13513 SRM 422, DIV 2 ,level 2. Here is my DP solution. But it is not working. Can someone please tell me the flaw in this code : #include"topheader.h" int prime(int i) { retur

Re: [algogeeks] Re: Easy Dp problem

2011-09-16 Thread mc2 .
Hey guys, I have the following grammar : S -> S{S}S or null i want to generate 2n number of brackets using this grammar. I gave it a try but my program is going out of stack.Could someone please help me code this grammar? On Fri, Sep 16, 2011 at 7:11 PM, mc2 . wrote: > thanks a lo

Re: [algogeeks] Re: Easy Dp problem

2011-09-16 Thread mc2 .
the possible bracket expressions are > > [][][][] * > [][][[]] > [][[]][] > [][[][]] > [][[[]]] > [[]][][] * > [[]][[]] > [[][]][] > [[][][]] > [[][[]]] > [[[]]][] > [[[]][]] > [[[][]]] > > > I have put *'s after the two cases that have [ at positions 5 a

[algogeeks] Easy Dp problem

2011-09-16 Thread mc2 .
Hey guys, i am trying to solve this problem : http://www.spoj.pl/problems/SQRBR/ But i can't decipher the problem what it is asking for . Could someone please give test cases for input set 4 and 5? What does proper proper bracket expressions mean in these cases? -- You received this message be

Re: [algogeeks] Re: Fwd: 8 queens problem

2011-09-01 Thread mc2 .
= 0; i < row; ++i) > if ((queens[row] == queens[i]) || > (queens[row] == (queens[i]-row+i)) || > (queens[row] == (queens[i]+row-i))) >break; > >// Try to fill remaining rows >if ((i == row) && placeQueens(row+1, queens)) return true; > } > //

[algogeeks] Fwd: 8 queens problem

2011-09-01 Thread mc2 verma
hey guys , I am trying to solve 8-queens problem using backtracking. Here is my algo. Could someone please tell me what is wrong in this code?? bool queen(int p,int count , int position[][]) { if(count == 8) return true; for(int i=p,i<8;i++) for(int j=0;j<8;j++) if(marked(i,j) =