Advertisement
PikMike

Untitled

Oct 4th, 2016
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. void dfs(int v, int &k){
  2.     used[v] = 1;
  3.     int u, w;
  4.     forn(i, sz(r[v])){
  5.         u = r[v][i].ft;
  6.         w = r[v][i].sc;
  7.         if (!used[u])
  8.             dfs(u, k);
  9.         if (d1[v] + d2[u] + w == k){
  10.             dp[v][0] += dp[u][0];
  11.             dp[v][1] += dp[u][1];
  12.         }
  13.         else if (d1[v] + d2[u] + w == k + 1){
  14.             dp[v][1] += dp[u][0];
  15.             if (d1[u] + d2[u] == k + 1)
  16.                 dp[v][1] += dp[u][1];
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement