Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void dfs(int i, vector<char> way, vector<vector<char> >& res) {
- if (ls[i].info.visited && ls[i].info.name != way[0])
- return;
- way.push_back(ls[i].info.name);
- res.push_back(way);
- ls[i].info.visited = true;
- for (Rebro* cur = ls[i].first_rebro; cur != nullptr; cur = cur->another_rebro) {
- dfs(cur->index_v_kakoy, way, res);
- }
- }
- void SimpleRoad() {
- vector<vector<char> > res;
- for (int i = 0; i < N; i++)
- {
- dfs(i, {}, res);
- for (int j = 0; j < N; j++)
- ls[j].info.visited = false;
- }
- for (auto& x : res) {
- for (auto &y : x)
- cout << y << ' ';
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement