Given a 2D matrix of size nxm (n, m <= 400), Calculate maximum submatrix such that all of its elements are distinct? [maximum submatrix is submatrix whose area is maximum]
P.S.
# | User | Rating |
---|---|---|
1 | tourist | 3845 |
2 | jiangly | 3707 |
3 | Benq | 3630 |
4 | orzdevinwang | 3573 |
5 | Geothermal | 3569 |
5 | cnnfls_csy | 3569 |
7 | jqdai0815 | 3532 |
8 | ecnerwala | 3501 |
9 | gyh20 | 3447 |
10 | Rebelz | 3409 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 171 |
2 | adamant | 163 |
3 | awoo | 162 |
4 | nor | 153 |
5 | maroonrk | 152 |
6 | -is-this-fft- | 151 |
6 | TheScrasse | 151 |
8 | Petr | 145 |
9 | pajenegod | 144 |
10 | orz | 143 |
Given a 2D matrix of size nxm (n, m <= 400), Calculate maximum submatrix such that all of its elements are distinct? [maximum submatrix is submatrix whose area is maximum]
I saw this problem on codeforces, but now I am not able to find it. solution approach or problem links are welcome:)
Name |
---|
407D - Largest Submatrix 3
Suppose you fix two rows of the matrix. Can you come up with a way of calculating the answer for this "slice" in O(m)?
Hint: Incrementing the "right" column will impose some constraints (lower bounds) on the "left" column.