#C131. Project Assignment Challenge
Project Assignment Challenge
Project Assignment Challenge
In a large company, employees are to be assigned to projects based on their skills. Each employee and project is labeled in the format name_skill
or project_skill
respectively. Your task is to assign employees to projects such that each employee gets at most one project and the total number of assignments is maximized. An employee can only be assigned to a project if their skill matches the required project skill. The assignment should follow a greedy strategy: for each skill, assign available employees to available projects in the order they appear in the input.
Note: The solution must read the input from stdin
and print the results to stdout
.
The matching must be presented as lines of text in the format employee -> project.
Input Format: The input consists of:
- An integer n representing the number of employees.
- n lines each containing a string in the format
employee_skill
. - An integer m representing the number of projects.
- m lines each containing a string in the format
project_skill
.
Output Format: Print each valid assignment on a separate line. If no assignments can be made, print nothing.
inputFormat
The input is provided via stdin and is structured as follows:
- The first line contains an integer n — the number of employees.
- The following n lines each contain a string representing an employee and their skill in the format
employee_skill
. - The next line contains an integer m — the number of projects.
- The following m lines each contain a string representing a project and its required skill in the format
project_skill
.
outputFormat
The output should be written to stdout and consist of zero or more lines. Each line represents an assignment in the format employee -> project
. The order of assignments should follow the input order based on a greedy matching for each skill.
3
alice_java
bob_python
charlie_java
2
project1_java
project2_python
alice -> project1_java
bob -> project2_python
</p>