Can someone give some hints to this problem from cf edu. Problem : D. Minimum maximum on the Path
Regards.
Can someone give some hints to this problem from cf edu. Problem : D. Minimum maximum on the Path
Regards.
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3690 |
2 | jiangly | 3647 |
3 | Benq | 3581 |
4 | orzdevinwang | 3570 |
5 | Geothermal | 3569 |
5 | cnnfls_csy | 3569 |
7 | Radewoosh | 3509 |
8 | ecnerwala | 3486 |
9 | jqdai0815 | 3474 |
10 | gyh20 | 3447 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 164 |
3 | adamant | 163 |
4 | TheScrasse | 159 |
5 | nor | 157 |
6 | maroonrk | 156 |
7 | -is-this-fft- | 152 |
8 | Petr | 146 |
8 | orz | 146 |
10 | BledDest | 145 |
Название |
---|
Binary search on the minimal possible maximum of the edges (aka answer)
If the maximum is some number x then you're only allowed to use edges with value less than or equal to x
Use a bfs on edges that satisfy the above condition to see if the final node is reachable in d edges, then reconstruct the path if it exists.
Hope that helps!
got it thanks
hey maxwellzen thanks for the hint, but how are you proving that it will be a .....1111110000.... or .....00000011111.... type of function in x.
I get this "If the maximum is some number x then you're only allowed to use edges with a value less than or equal to x" but how can we say that this x is the optimal answer, or no other x left or right to it?
If you can connect node 1 to node n in a way such that the maximum edge has a value at most x, then you guarantee that you can connect node 1 to node n in a way such that the maximum edge has a value greater than or equal to x. Therefore, the BS check function has the form ..00000111111..
can we apply dfs also ?
Yep!
Can you share your dfs code