[algogeeks] Re: Room Permutation Algorithm

2009-07-10 Thread Spiritus
Yep, something like define A[1..n] Gen(k, l): if(k==0) print A; for(i=1; i<=l; i++) Gen(k-1, A[k]=i); And, in your case, you should call Gen(n, 3), since you want it with 3 numbers (e.g. s,d,t will equal 1,2,3) On Jul 9, 12:18 pm, Miroslav Balaz wrote: > LOL, you should heve some

[algogeeks] Re: Acm programming competition Questions in year 2004-2005

2009-07-10 Thread Spiritus
, 5:48 am, Spiritus wrote: > I have an idea for D as well. > > First, suppose we are given an upper bound T on the projects finish > time. we thus want to assign jobs for each employee that this > employees total time doesn't exceed this upper bound T. > This we can do using d

[algogeeks] Re: Acm programming competition Questions in year 2004-2005

2009-07-10 Thread Spiritus
out 1,000,000. All that we have to do now is to binary search the value for T, this adds a log T, so overall, we have O(M^2 * N * lg T) On Jul 10, 5:15 am, Spiritus wrote: > Problem B: > My idea is to have a set(can be implemented using STL's std::set) with > key being a pair (dx,

[algogeeks] Re: Acm programming competition Questions in year 2004-2005

2009-07-10 Thread Spiritus
product. This is, I believe, if Im not completely mistaken, O(M log N + N log N). On Jul 10, 5:15 am, Spiritus wrote: > Problem B: > My idea is to have a set(can be implemented using STL's std::set) with > key being a pair (dx,dy). > now, i go through all pairs of points, and i

[algogeeks] Re: Acm programming competition Questions in year 2004-2005

2009-07-10 Thread Spiritus
Problem B: My idea is to have a set(can be implemented using STL's std::set) with key being a pair (dx,dy). now, i go through all pairs of points, and i construct the key(x_1- x_0,y_1,y_0) for them. The idea is that if i have L pairs each with the same (dx,dy), every two pairs make a parallelogram

[algogeeks] Re: Problem

2006-11-08 Thread Spiritus
Yeah, its from ioi. 1)the solution is on their site. basically there are like 6 ways to put rectangles together given their order and orientation. so, you just loop through all permutations and orientation, and try each of the 6 possibilities(which are shown on their site), and select a minimum.

[algogeeks] Re: help =/

2006-10-08 Thread Spiritus
1. u should calculate the k variable, that is if i+j=3 (i=1, j=2, or vice versa) then k=3 if i+j=4 (i=1, j=3, or vice versa) then k=2 if i+j=5 (i=2, j=3, or vice versa) then k=1 2. the last question give the answer to the last 2: T(m) = 1 if n = 1 2*T(m - 1) + 1 if n > 1 is the reccurence relati

[algogeeks] Re: Solution needed !!

2006-09-11 Thread Spiritus
You first find the greatest N values for each array.(No need for it here, because both arrays are of size N) The first pair will be both maximums(or maxima, actually, in greek). then, in a way of Merge(Nonincreasing order), we pick the next pairs. --~--~-~--~~~---~--~