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 | 3707 |

2 | Benq | 3672 |

3 | Radewoosh | 3627 |

4 | ksun48 | 3547 |

5 | Miracle03 | 3480 |

6 | ecnerwala | 3400 |

7 | peehs_moorhsum | 3384 |

8 | maroonrk | 3361 |

9 | sunset | 3338 |

10 | Um_nik | 3320 |

# | User | Contrib. |
---|---|---|

1 | 1-gon | 209 |

2 | Um_nik | 196 |

3 | YouKn0wWho | 192 |

4 | Errichto | 182 |

5 | awoo | 181 |

6 | sus | 180 |

7 | tourist | 175 |

8 | -is-this-fft- | 171 |

8 | SecondThread | 171 |

10 | Radewoosh | 170 |

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

↑

↓

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/20/2021 07:56:06 (f1).

Desktop version, switch to mobile version.

Supported by

User lists

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.

Vector of pairs is basically adjacency matrix

then don't use it.

to be honest, you don't need bfs to get to pupil

even you don't need bfs to get to specialist

You can use GreeksForGeeks for better understanding.

Yes nrg_aceu go there

it uses OOP.i dont udnerstand OOP.

// A Quick implementation of BFS using // vectors and queue

## include <bits/stdc++.h>

## define pb push_back

using namespace std;

vector v; vector<vector > g;

void edge(int a, int b) { g[a].pb(b);

}

void bfs(int u) { queue q;

}

// Driver code int main() { int n, e; cin >> n >> e;

}

Where the fuck do you find oop here?Search CodeNCode graph playlist on YT

refer codencode utube channel and study graphs from there. If u find it useful then thank me later

I would suggest you to watch the amazing graph series by striver_79 He has explained each and every concept very well. Here is the link to the playlist: Striver's Graph Series

do you even understand how bfs works?

Go through the graph theory playlist by William Fiset. Here's the link it has neat visualization and implementation as well. https://www.youtube.com/playlist?list=PLDV1Zeh2NRsDGO4--qE8yH72HFL1Km93P