In short, You are given the value of N, now determine in how many ways you can completely tiled a 3xN rectangle with 2x1 dominoes. Here is a possible soln: Algorithmist — UVa 10918. My question is, how is the recurrence defined? Here,
******** AA******* AA****** A*******
******** = BB******* + B******* + A*******
******** CC******* B******* BB******
f(n) = f(n-2) + g(n-1) + g(n-1)
Isn't it possible as:
******** AA******* AA****** AA******
******** = BB******* + BA****** + AA******
******** CC******* BA****** BB******
f(n) = f(n-2) + f(n-2) + f(n-2)
or like others....(actually I want to know it). How can I define such type of recurrence?
Actually I want to know, what type of thinking should I keep in mind while defining recurrence for Tiling Block problem???
Thanks in advanced. :)
You don't have to do it in O(N) time...
You can continue to put dominoes and do it in O(N^2)... (I wish I'm not wrong)
For example:
NOTE : I want to sleep now and don't have time but I think maybe you can do this in O(N) too...by saving sum of all f(2i) and f(2i+1) in two integers
Searching for good tutorials about dynamic programming approach for this problem, I have accidentally found this presentation. The guys claim they can find the number of domino tilings of the m × n rectangle in polynomial time (it seems like O((nm)3) algorithm). I haven't had time to understand the full presentation yet, but this fact was quite unexpected to me. Have you guys heard about it before? :)
Yes, for example, see acm.timus.ru problem "Aztec treasure" ("Сокровища ацтеков"), here is such problem for 100x100 grid =))
This interesting method firstly was presented to ACM in Petrozavodsk winter camp 2009. Team of Yekaterinburg try to tell us solution, which was described in some big article (40-50 pages in size).
If you want, I can see for some hint or link for you.
Can you give me this article, please? I solved this problem several years ago but almost forgot solution.
Proof: http://acm.timus.ru/status.aspx?space=&num=1594&author=64460
Ok, I can search it in the evening later... Don't promise that really have this article now, I'm not sure.
time is O((n+m)^3), not O((n*m)^3)
As for your question, you can find some clues in this tutorial.
Thanks for your link, It's very helpful and fun also =))