← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You are given a list of employee-manager pairs representing the reporting structure of a company. Each pair is of the form [employee, manager] where both are strings. The CEO has no manager (no incoming edge). Build the organizational tree and support two queries:
Input is first the number of pairs, followed by that many pairs. After the pairs, commands are given: "chain <employee>" or "common <e1> <e2>". Process each command and output accordingly.