I was trying to solve this problem . I even searched for solution but was unable to understand .Can any one explain how to solve it.
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3857 |
2 | jiangly | 3747 |
3 | orzdevinwang | 3706 |
4 | jqdai0815 | 3682 |
5 | ksun48 | 3591 |
6 | gamegame | 3477 |
7 | Benq | 3468 |
8 | Radewoosh | 3463 |
9 | ecnerwala | 3451 |
10 | heuristica | 3431 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | -is-this-fft- | 161 |
3 | Qingyu | 160 |
4 | Dominater069 | 159 |
5 | atcoder_official | 157 |
6 | adamant | 153 |
7 | Um_nik | 152 |
8 | djm03178 | 151 |
9 | luogu_official | 150 |
10 | awoo | 147 |
I was trying to solve this problem . I even searched for solution but was unable to understand .Can any one explain how to solve it.
Название |
---|
Problem statement: http://www.spoj.com/problems/ADFRUITS/
The thing that you are looking for is called shortest common supersequence(or just SCS).
The length of SCS(a,b) and be computed using simple DP:
Let dp[i][j] is the length of the shortest common supersequence of a[1],...,a[i] and b[1],...,b[j].
Then there are two cases:
1) If a[i]=b[j], then dp[i][j]=1+dp[i-1][j-1].
2) If a[i]!=b[j], then dp[i][j]=1+min(dp[i-1][j],dp[i][j-1]).
Now, think how to restore the SCS after computing the dp array.
Got it....thanks again