Tags:
create new tag
view all tags
bool match(int now){
  for(int i = 0; i < (int)g[now].size(); i++){
    if(vis[g[now][i]] || now == a && g[now][i] == b || 
       now == b && g[now][i] == a) continue;
    vis[g[now][i]] = 1;
    if(m[g[now][i]] == -1 || !vis[m[g[now][i]]] && match(m[g[now][i]]))
      { m[g[now][i]] = now; m[now] = g[now][i]; return true; }
  }
  return false;
}

//memset(m, -1, sizeof(m));
//for(int i = 0; i < n; i++)
//  if(m[i] == -1) memset(vis, 0, sizeof(vis)), match(i);

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r3 - 2005-11-18 - MatthewChan
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback