I was trying a problem on LCS topic and was stuck. It will be really helpful if anyone can provide me a hint to the problem.
Problem :-ADASEED
№ | Пользователь | Рейтинг |
---|---|---|
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 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
I was trying a problem on LCS topic and was stuck. It will be really helpful if anyone can provide me a hint to the problem.
Problem :-ADASEED
Название |
---|
Auto comment: topic has been updated by humblefoolboi (previous revision, new revision, compare).
Hello Chauhan saab
$$$ \frac{N}{L} \le 100$$$ suggests that we can try out the pairing of same colors as they are fewer.
One solution would be to first make all pairs of same color (with pair I mean we want them at same position in our last sequence). If we want $$$x$$$ and $$$y$$$ to be at same position, then $$$\forall\ i$$$ where $$$ min (x, y) \le i\ \le max (x, y)$$$, $$$A_{i}$$$ and $$$B_{i}$$$ must be choped (supposing A and B the given two array). This would mean after forming all pair we should select some such that they don't overlap (while of course maximizing length) but probably it will TLE if we select literally all pairs.
For any index $$$i$$$ if we try finding other index $$$j$$$ from other array such that $$$i \le j$$$, I don't think it makes sense to try more than one as the smallest such $$$j$$$ should be better than rest surely so therefore we don't take all the pairs one for each (as a starting) from both arrays this might make it in time but not sure enough.
Just realized second part is pure crap. I does make sense to try more than one.