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 | 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 |
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.