Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. struct Edge {
  2.     int u;
  3.     int v;
  4.     int al;
  5.  
  6.     Edge(int u_, int v_) {
  7.         u = u_;
  8.         v = v_;
  9.         al = 1;
  10.     }
  11. };
  12.  
  13. vector<Edge> ed;
  14. vector<int> g[SZ];
  15. int pnt[SZ];
  16. vector<int> tour;
  17.  
  18. void dfs(int cur) {
  19.     int cnt = 0;
  20.     for (; pnt[cur] < (int)g[cur].size(); pnt[cur]++) {
  21.         int t = g[cur][pnt[cur]];
  22.         int v = ed[t].v;
  23.         if (v == cur) {
  24.             v = ed[t].u;
  25.         }
  26.         if (ed[t].al) {
  27.             ed[t].al = 0;
  28.             dfs(v);
  29.             cnt++;
  30.         }
  31.     }
  32.     tour.push_back(cur);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement