Can Anyone give the idea for the following Problem UVALIVE — 7887 Back To The Future
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3831 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | gamegame | 3386 |
10 | ksun48 | 3373 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
Can Anyone give the idea for the following Problem UVALIVE — 7887 Back To The Future
Name |
---|
First of all lets build a graph with the metal pieces being the nodes and with edges connecting compatible metals. Now what the problem is asking us is to find the largest subgraph (not necessarily connected) such that for each node u in this subgraph the following property holds: A ≤ deg[u] ≤ N - B - 1. Now it all comes down to constructing this subgraph efficiently. We can do this using the following strategy:
1) Start with the whole graph as your subgraph
2) Check if this subgraph is OK. Notice that we can do this by checking if the property holds only for the nodes with the lowest and highest degrees.
3) If it doesn't hold then remove the node for which the property doesn't hold from your subgraph. Go back to (2).
You can do this efficiently by using a set.
Here is my accepted code for the problem.
Got AC ... Thanks A lot ... Did You Solve UVALIVE-7896? @giorgosgiapis