Difference: Code_BPTShort (1 vs. 2)

Revision 22005-11-18 - MatthewChan

Line: 1 to 1
 
META TOPICPARENT name="ProgrammingContest"
bool match(int now){
Line: 17 to 17
 // if(m[i] == -1) memset(vis, 0, sizeof(vis)), match(i);
Changed:
<
<
>
>
 

Revision 12005-11-17 - YuryKholondyrev

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="ProgrammingContest"
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);

 
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