#K84817. Employee Management System

    ID: 36504 Type: Default 1000ms 256MiB

Employee Management System

Employee Management System

You are given a sequence of operations to manage an employee database. Each operation can add or update an employee's department, remove an employee, find the department for a given employee, or list all employees in a department in sorted order. The commands have the following formats:

  • ADD X Y: Add employee Y to department X. If employee Y already exists, update their department to X.
  • REMOVE Y: Remove employee Y from the records.
  • FIND Y: Output the department where employee Y is; if not found, output an appropriate message.
  • LIST X: List all employees in department X in increasing order. If no employees exist in department X, output an appropriate message.

All operations are processed sequentially. For the commands FIND and LIST, output the results immediately.

Note that updating an employee's department is equivalent to a removal from the former department and an addition to the new one.

The operations can be summarized by the following update rule in \( \LaTeX \):

\[ \text{If } \text{employee}(Y) \text{ exists in department } D_1 \text{ and an } \texttt{ADD } X\,Y \text{ command is issued, then update } D_1 \text{ to } X. \]

inputFormat

The first line contains an integer \( Q \) representing the number of queries. Each of the following \( Q \) lines contains a query command in one of the formats: ADD X Y, REMOVE Y, FIND Y, or LIST X.

outputFormat

For each FIND or LIST command, output one line with the corresponding result. The format for FIND queries is: "Employee Y is in department X" if employee Y exists, otherwise "No employees in department Y". For LIST queries, output the sorted list of employee IDs separated by spaces, or "No employees in department X" if the department is empty.

## sample
9
ADD 2 101
ADD 3 102
ADD 2 103
FIND 101
LIST 2
REMOVE 101
FIND 101
ADD 2 104
LIST 2
Employee 101 is in department 2

101 103 No employees in department 101 103 104

</p>