Last active
July 14, 2024 15:04
-
-
Save ajx42/9e13c7ba62b3741eb5d96f45eea67cc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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