#K59647. Employee Role Manager

    ID: 30911 Type: Default 1000ms 256MiB

Employee Role Manager

Employee Role Manager

You are given a list of employees with their associated roles. Your task is to implement an employee management system that can perform the following operations:

  1. Add Operation: Add a new employee with a given role. Although a unique employee ID is provided, the system will assign the next sequential ID.
  2. Update Operation: Update the role of an existing employee. The operation specifies the employee ID and the new role.
  3. Query Operation: Query the number of employees with a specific role in the range from index \(L\) to \(R\) (inclusive). Note that the employees are indexed starting from 1.

Implement the operations accordingly and for each query operation, output the answer.

inputFormat

The first line contains two integers \(N\) and \(Q\) where \(N\) is the initial number of employees and \(Q\) is the number of operations to be performed.

The second line contains \(N\) space-separated integers where the \(i\)-th integer represents the initial role of the \(i\)-th employee.

This is followed by \(Q\) lines, each describing an operation in one of the following formats:

  • For add operation: 1 id role (the id is provided but can be ignored as the system assigns the next available ID)
  • For update operation: 2 id new_role
  • For query operation: 3 L R role

outputFormat

For each query operation (operation type 3), output a single line containing the number of employees with the specified role in the range \(L\) to \(R\) (inclusive).

## sample
5 4
1 2 3 4 5
1 6 1
2 2 3
3 1 5 1
3 2 4 3
1

2

</p>