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
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
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
Название |
---|
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.