How to reconstruct all possible solutions of a particular DP problem? I'm not able to get a generalized technique for this and only results for LCS are shown regarding an example of this topic.
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
How to reconstruct all possible solutions of a particular DP problem? I'm not able to get a generalized technique for this and only results for LCS are shown regarding an example of this topic.
Name |
---|
Erm. There is no "universal" technique. So which DP problem are you trying to address in particular?
LCS and LIS
When you see a DP problem, you shouldn't try to frame your solution around some general approach. Each problem is unique (unless its a dumb problem) so you should make some observations beforehand which may lead to a recurrence.
No, I'm not asking about DP recurrences, I'm asking about some ideas regarding the reconstruction of all possible solutions after running the DP recurrence. Like there is the parent pointer technique to get one of the possible solutions of the problem.
Just store array of parent positions of a certain dp state and backtrack.
For this, is backtracking a must?
Yeah
Ok, thanks btw
How to do LCS reconstruction when space-optimized bottom-up DP(Space Complexity = O(n)) is used?
You may take a look at: this blog and comment
How to reconstruct solution for this problem: https://mirror.codeforces.com/contest/10/problem/D