Hi all,
I have tried to write a tutorial on how matrix exponentiation can be used in dynamic programming. Check the post out!
http://threads-iiith.quora.com/Solving-Dynamic-Programming-with-Matrix-Exponentiation
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 156 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Hi all,
I have tried to write a tutorial on how matrix exponentiation can be used in dynamic programming. Check the post out!
http://threads-iiith.quora.com/Solving-Dynamic-Programming-with-Matrix-Exponentiation
Name |
---|
There is a neater and more intuitive way (in my opinion) to realize the solutions of the non linear recurrences.
It uses the number of paths in a graph of length N. (Exponentiate the adjency matrix of the graph to N and the value of the (i, j)th element in the exponentiated matrix is the number of paths of length N from the ith vertex to jth vertex).
Now, in each of these problems, consider the states as vertices and keep on adding edges from each vertex and then find the answer. :)
Like, in "ASC1 Nice Patterns Strike Back", each bitmask is a vertex, from each bitmask, find to which all bitmasks you can go by checking all of the others. The graph is made! Now simply exponentiate and find the answer! :)
In, World War II, a vertex will be represented in a triplet (i, j) i.e. (coloumn number, row number % 2) i.e. a total of 60 vertices. According to the given rules, the transitions should be fairly obvious. :)
Finally in "Solving the Practice contest", a vertex is a triplet, (number of problems coded by k % K, was the last problem coded by J, has V coded any problem), there are 40 such vertices. Once you build the graph and exponentiate, the answer will be the number of paths from (0, 0, 0) to (0, 1, 1) and from (0, 0, 0) to (0, 0, 1). :D