You are given information about a group of employees in a company.
Each employee has the following attributes:
typedef struct {
int id;
char firstname[32];
char lastname[32];
int boss_id;
} employee;
a unique employee ID (id)
a first name (firstname)
a last name (lastname)
the employee ID of their direct supervisor (boss_id)
If an employee’s boss_id is the same as their own id, it means that person is the top boss.
All employees and their supervisors appear in the input list.
Two employees A and B share the same direct supervisor if there exists a person C such that both employees have boss_id = C.id.
You need to determine, for several pairs of employees, whether they have the same direct supervisor.
The first line contains an integer n, the number of employees.
The next n lines each contain:
id firstname lastname boss_id
The next line contains an integer m, the number of queries.
The next m lines each contain the names of two employees:
firstname1 lastname1 firstname2 lastname2
All queried employees exist in the list and are distinct.
For each query, output yes if the two employees have the same direct supervisor, otherwise output no.
Ensure that the output format exactly matches the sample.