Can any one explain the topic and also tell me the list of some good problems.Thanks in advance.
| # | User | Rating |
|---|---|---|
| 1 | jiangly | 3810 |
| 2 | Benq | 3676 |
| 3 | Kevin114514 | 3655 |
| 4 | maroonrk | 3463 |
| 5 | strapple | 3447 |
| 6 | Um_nik | 3387 |
| 7 | heuristica | 3322 |
| 8 | turmax | 3317 |
| 9 | tourist | 3307 |
| 10 | jiangbowen | 3291 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 155 |
| 2 | nik_exists | 150 |
| 2 | maspy | 150 |
| 4 | Um_nik | 141 |
| 5 | Errichto | 139 |
| 6 | adamant | 137 |
| 7 | AmShZ | 136 |
| 8 | BledDest | 132 |
| 9 | maroonrk | 131 |
| 10 | qwexd | 129 |
| Name |
|---|



https://codeforces.me/contest/1272/problem/E
Another way to think about multiple sources that's potentially nicer to code is to add a fake source with edges to all the real sources, then BFS as normal, then subtract 1 from all the distances.
can you please elaborate what are you trying to tell ?
Imagine this is your original graph (not including the red node/edges), and
A,B,Care your multiple sources. We can create an additional nodeXand the red edges shown, then do a standard BFS starting from X. Finally, all the distances will be 1 more than they should be, because you had the extra hop fromXto the real source at the beginning of each path.Wow!
great thought !!
Thank you :)
Sir, how does it affects the time complexity? does it make any difference at all.
I think there should be no huge differences. As our red coder said above, it's just nicer to code, as traditionally, you start with a single vertex only.
If I misunderstand anything, please tell me.
Another Problem: 986A - Fair
Add all the nodes you want to BFS from into the initial queue and run it.
I love this community. Thanks for various approaches on multi source BFS.
This is a nice problem illustrating the use of multiple source BFS: Monsters
You should do "monsters" problem on cses.
A little addition over multi-source bfs
thanks, this one is quite intuitive through multi-source bfs