Skip to content

Instantly share code, notes, and snippets.

@ajx42
Last active July 14, 2024 15:04
Show Gist options
  • Save ajx42/9e13c7ba62b3741eb5d96f45eea67cc0 to your computer and use it in GitHub Desktop.
Save ajx42/9e13c7ba62b3741eb5d96f45eea67cc0 to your computer and use it in GitHub Desktop.
cin >> x >> u; // input id for newly added node and its to-be manager
// lets assume we have the parent array created for us already
// lets add parent for newly added node x
parent[x] = u;
// add 1 to all nodes on path towards root
int curr = x;
while(curr != -1){
attending[curr]++;
curr = parent[curr];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment