11379 - Chichi's Home Work
Moderator: Board moderators
11379 - Chichi's Home Work
Nevermind,... I got it...
-
- Experienced poster
- Posts: 196
- Joined: Wed May 02, 2007 10:12 pm
- Location: Hungary, Pest county, Halasztelek
- Contact:
Heres some hint how I solved.
For example, f(3,2) is 3.
Using c(n) and f(n,k), you could get the answer with O(n).
-----
Rio
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.
Code: Select all
()()(), (())(), (()())
-----
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:
Written in "Real Time Clarification".
-----
Rio
PS: Be careful that the correct output for the sample input will be:
Code: Select all
57
774474320
-----
Rio
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?
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.
still struggling...
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.
Re: still struggling...
I dont understand, what do you mean by that? ( circles should not intersect... could you give like an example?) gl! Eric.baodog wrote: It gets complicated when circles at the ends of the interval [X,Y] intersect with ones before it, or after it.