Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void divideandconquer(int current, int total)
- {
- if(total == 1)return;
- dfs(current, -1);
- int newcenter = findcenter(current, -1, total);
- delete[center] = 1;
- // Add the conditions needed to be checked with the current center
- int sum = 0, nextinline = -1;
- for(int i=0;i<(int)adjacency_list[center].size();i++)
- {
- int next = adjacency_list[center][i];
- if(delete[next])continue;
- if(size[next] < size[center])
- {
- divide_conquer(next, size[next] + 1);
- sum += size[next] + 1;
- }
- else
- nextinline = next;
- }
- if(nextline != -1)
- divide_conquer(nextinline, total - sum - 1);
- return ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement