#K1661. Team Building Group Assignment
Team Building Group Assignment
Team Building Group Assignment
A company is organizing a team building activity where employees are divided into groups. Each group can have at most \( g \) employees. For the activity to succeed, every group must have at least one member with a unique skill set compared to the rest of the group. Each employee's skill set is represented by an integer ID.
You are given \( n \) employees and the maximum group capacity \( g \). You are also provided with a list of \( n \) integers where each integer denotes the skill ID of an employee. Your task is to assign employees to groups such that:
- No group exceeds \( g \) employees.
- If an employee's skill appears more than \( g \) times, it is impossible to form groups that satisfy the requirement (since at least one member in a group needs a unique skill relative to the rest).
- If it is possible to form the groups, output "YES" followed by the group assignments. Each group assignment is a list of the 1-indexed employee numbers. If it is impossible, simply output "NO".
Note: The grouping algorithm used here assigns employees to groups in a round-robin fashion once the feasibility condition is met.
inputFormat
The first line contains two space-separated integers: \( n \) (the number of employees) and \( g \) (the maximum number of employees per group).
The second line contains \( n \) space-separated integers representing the skill IDs of the employees.
outputFormat
If the assignment is possible, output "YES" on the first line, followed by one line per group. Each group line contains the indices (1-indexed) of employees in that group separated by a single space.
If it is not possible to form groups satisfying the condition, output a single line with "NO".
## sample5 2
1 2 3 4 5
YES
1 4
2 5
3
</p>