Hello, I have been trying to solve the following problem which was a part of Topcoder SRM 696 Div1 Easy.
I am unable to find a editorial for the problem and I am not able to solve it. Can someone please tell me how to approach this problem ?
# | User | Rating |
---|---|---|
1 | jiangly | 3976 |
2 | tourist | 3815 |
3 | jqdai0815 | 3682 |
4 | ksun48 | 3614 |
5 | orzdevinwang | 3526 |
6 | ecnerwala | 3514 |
7 | Benq | 3482 |
8 | hos.lyric | 3382 |
9 | gamegame | 3374 |
10 | heuristica | 3357 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | -is-this-fft- | 166 |
3 | Um_nik | 161 |
3 | atcoder_official | 161 |
5 | djm03178 | 157 |
6 | Dominater069 | 156 |
7 | adamant | 154 |
8 | luogu_official | 152 |
9 | awoo | 151 |
10 | TheScrasse | 147 |
Hello, I have been trying to solve the following problem which was a part of Topcoder SRM 696 Div1 Easy.
I am unable to find a editorial for the problem and I am not able to solve it. Can someone please tell me how to approach this problem ?
Name |
---|
Let's M is set of all vertices, that have degree more than 1. If there are edges where both vertices have degrees 1 — add one vertex from each such edge to M.
You can see that size of M is no more than 20. So wee can color all vertices not in the M, after that write dp[mask] = mininal fee if mask — colored vertices from M.
Can you please elaborate a little more, I am not able to understand the purpose of the set M ?
Imagine, that you have only 20 vertices in graph — you could brute all bitmasks of vertex subsets and write dp[mask] without problem.
But there you have 50 vertices, but only 20 edges. So I divide all vertices on two sets: set M, for subsets of that dp[mask] can be written, and all other, that can be colored before set M and will be constantly colored while calculating answer for dp.
Set M includes all vertices, that have degree 2 and more, and one (not both) of the vertices from edge, where both vertices have degree 1. It's obvious, that maximal size of set M is 20, that acceptable for dp in bitmasks.