Can any one explain the topic and also tell me the list of some good problems.Thanks in advance.
# | 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 |
Name |
---|
https://mirror.codeforces.com/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
,C
are your multiple sources. We can create an additional nodeX
and 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 fromX
to the real source at the beginning of each path.Wow!
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.