i read cp algorithm and understand bfs theory.when it comes to implementation i cant. see this code https://pastebin.com/5RtDSMMW this is literally copying yet its still wrong idk whats wrong.pls help
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
i read cp algorithm and understand bfs theory.when it comes to implementation i cant. see this code https://pastebin.com/5RtDSMMW this is literally copying yet its still wrong idk whats wrong.pls help
Name |
---|
pls help.im tired of asking someone in discord since theyll just ignore me.i really want to learn bfs and i cant.
https://cses.fi/book/book.pdf
that book is the worst.it left me confused at the implementation like what am i suppose to write in int main? whenever i tried to see the implementation example it just wont print anything.
If you can't implement bfs by your own in main function despite having the bfs structure ready, then you have lack of understanding of bfs, that's not the fault of the book
what i dont understand is actually the variations.some use vector<vectir> for storing adj list for bfs and some use vector pair.i was confused since in the article i read it uses vector vector and what i elarn from my teacher is vector pair.this also applies to that book.the standards are different
I don't know how the vector of pairs implementation works, but vector of vectors is used because for a vector with index $$$i$$$, all the values in that vector are neighbours of $$$i$$$. For example if 1,2,3 are stored in vector adj[0], then nodes 1,2,3 are neighbours of node 0. This way after processing node 0, you can push it's neighbours (1,2,3) in the queue for processing.