Advertisement
CyberN00b

Untitled

Jan 4th, 2023
762
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1.  
  2. void dfs(int i, vector<char> way, vector<vector<char> >& res) {
  3.     if (ls[i].info.visited && ls[i].info.name != way[0])
  4.         return;
  5.     way.push_back(ls[i].info.name);
  6.     res.push_back(way);
  7.     ls[i].info.visited = true;
  8.     for (Rebro* cur = ls[i].first_rebro; cur != nullptr; cur = cur->another_rebro) {
  9.         dfs(cur->index_v_kakoy, way, res);
  10.     }
  11. }
  12.  
  13. void SimpleRoad() {
  14.     vector<vector<char> > res;
  15.     for (int i = 0; i < N; i++)
  16.     {
  17.         dfs(i, {}, res);
  18.         for (int j = 0; j < N; j++)
  19.             ls[j].info.visited = false;
  20.     }
  21.     for (auto& x : res) {
  22.         for (auto &y : x)
  23.             cout << y << ' ';
  24.         cout << endl;
  25.     }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement