#C9310. Project Management System

    ID: 53390 Type: Default 1000ms 256MiB

Project Management System

Project Management System

You are required to implement a Project Management System that supports dynamic assignment and unassignment of employees to projects. The system must handle four types of operations:

  • assign e p: Assign employee e to project p.
  • unassign e p: Remove the assignment of employee e from project p (if it exists).
  • projects e: Query and report (in sorted order) all projects assigned to employee e.
  • employees p: Query and report (in sorted order) all employees assigned to project p.

For the queries, the output should list the numbers in ascending order separated by a single space. If there are no assignments, output an empty line.

Note: In this problem, employee and project identifiers are positive integers. You need to process the operations sequentially.

Mathematically, you can view the assignment operations as maintaining two relations. Let \(E\) be the set of employees and \(P\) be the set of projects. An assignment is a relation \(R \subseteq E \times P\). Then the query operations are defined as:

  • \(projects(e) = \{ p \in P : (e,p) \in R \}\)
  • \(employees(p) = \{ e \in E : (e,p) \in R \}\)

inputFormat

The input is read from standard input and has the following format:

q
operation_1
operation_2
...
operation_q

Here, q is an integer indicating the number of operations. Each subsequent line contains one operation. The operations can be one of the following forms:

  • assign e p
  • unassign e p
  • projects e
  • employees p

For each assign or unassign operation, e and p are integers. For projects and employees queries, a single integer is provided as specified.

outputFormat

For every query operation (projects or employees), output a single line containing the sorted list of integers corresponding to the answer. The numbers should be separated by a single space. If no assignments exist for a query, output an empty line.

## sample
5
assign 1 2
assign 1 3
projects 1
assign 2 3
projects 2
2 3

3

</p>