Can someone give some hints to this problem from cf edu. Problem : D. Minimum maximum on the Path
Regards.
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3839 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3612 |
7 | Geothermal | 3569 |
7 | cnnfls_csy | 3569 |
9 | ecnerwala | 3494 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | Um_nik | 164 |
2 | maomao90 | 160 |
3 | -is-this-fft- | 159 |
4 | atcoder_official | 158 |
4 | awoo | 158 |
4 | cry | 158 |
7 | adamant | 155 |
8 | nor | 154 |
9 | maroonrk | 151 |
9 | TheScrasse | 151 |
Can someone give some hints to this problem from cf edu. Problem : D. Minimum maximum on the Path
Regards.
Название |
---|
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
I DID THE SAME BUT MY CODE KEEP GETTING REJECTED AT TEST 45 DUE TIME LIMIT, CAN YOU SHARE SOME MINOR DETAILS, I USED DFS