11379 - Chichi's Home Work

All about problems in Volume 113. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
baodog
Experienced poster
Posts: 202
Joined: Wed Jul 04, 2007 6:53 am

11379 - Chichi's Home Work

Post by baodog »

Nevermind,... I got it...
Robert Gerbicz
Experienced poster
Posts: 196
Joined: Wed May 02, 2007 10:12 pm
Location: Hungary, Pest county, Halasztelek
Contact:

Post by Robert Gerbicz »

How is it solvable? I know only that the total number of ways to place n circles (without x,y restrictions) is the n-th Catalan number. I've tried recursion, but it wasn't worked.
rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Post by rio »

Heres some hint how I solved.

Code: Select all

c(n) := total numbers of ways to place n circles (Catalan number)
f(n, k) := total numbers of ways to place n circles with k'th circle does not include any other circles.
For example, f(3,2) is 3.

Code: Select all

()()(), (())(), (()())
Using c(n) and f(n,k), you could get the answer with O(n).
-----
Rio
sonyckson
New poster
Posts: 49
Joined: Tue Feb 06, 2007 9:29 pm
Location: Cordoba, Argentina

Post by sonyckson »

Hello, any hints for calculating f(n,k) in less than n^3 ( using dp )?? Thanks, Eric.
baodog
Experienced poster
Posts: 202
Joined: Wed Jul 04, 2007 6:53 am

Post by baodog »

With precomputation f can be computed in O(n^2) dp, which
may or may not be fast enough
rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Post by rio »

I calculated f(n,k) with O(n^2) DP using c(n).

PS: Be careful that the correct output for the sample input will be:

Code: Select all

57
774474320
Written in "Real Time Clarification".
-----
Rio
suhendry
New poster
Posts: 14
Joined: Sat Aug 31, 2002 6:55 am

Post by suhendry »

Arggh! so there's a clarification :-( They haven't fixed the sample output for this problem yet.

Thanks Rio.
Suhendry Effendy
tobby
Learning poster
Posts: 98
Joined: Fri Dec 30, 2005 3:31 pm

Post by tobby »

Can anyone share some hint how to compute f(n,k) in O(n^2)? Mine is too slow. O(n^3).
sonyckson
New poster
Posts: 49
Joined: Tue Feb 06, 2007 9:29 pm
Location: Cordoba, Argentina

Post by sonyckson »

Suppose that g(n, k) is the number of ways of placing n circles with the k-th including at least one circle :).
Now, f(n, k) = c(n)-g(n,k);........ think about g :). gl! Eric.
tobby
Learning poster
Posts: 98
Joined: Fri Dec 30, 2005 3:31 pm

Post by tobby »

Your hint is great! After reading your hint I rewrite my code in 10 minutes and get AC. How do you get this awesome idea?

Instead of bottom-up dp, my code uses top-down memoization. Would precomputing f(n, k) using dp be faster?
Last edited by tobby on Fri Jan 11, 2008 11:26 am, edited 4 times in total.
sonyckson
New poster
Posts: 49
Joined: Tue Feb 06, 2007 9:29 pm
Location: Cordoba, Argentina

Post by sonyckson »

In my case it took me some hours... and the hint above that f(n,k) could be computed in O ( n^2 )... is a good hint to start thinking... because it gives some information about how f(n,k) may be defined :). gl! Eric.
baodog
Experienced poster
Posts: 202
Joined: Wed Jul 04, 2007 6:53 am

still struggling...

Post by baodog »

I can get f(n,k), but not the rest from it. It gets complicated when circles at the ends of the interval [X,Y] intersect with ones before it, or after it. I can not get the right answer using inclusion exclusion principle.
sonyckson
New poster
Posts: 49
Joined: Tue Feb 06, 2007 9:29 pm
Location: Cordoba, Argentina

Re: still struggling...

Post by sonyckson »

baodog wrote: It gets complicated when circles at the ends of the interval [X,Y] intersect with ones before it, or after it.
I dont understand, what do you mean by that? ( circles should not intersect... could you give like an example?) gl! Eric.
Post Reply

Return to “Volume 113 (11300-11399)”