a guest Nov 22nd, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def dfs(v, now):               #now - цвет, в который красим v. равен 1 или 2
  2.     color[v] = now             #собственно, красим v в цвет now
  3.     for to in graph[v]:
  4.         if color[to] == 0:     #если эта вершина еще не покрашена
  5.             dfs(to, 3 - now)   #то запускаем dfs от нее, сменив цвет
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand