#C14898. Student Schedule Generator
Student Schedule Generator
Student Schedule Generator
You are given a fixed mapping from subjects to their available time slots and a list of students. Each student provides a list of preferred subjects and a list of available time slots. Your task is to generate a schedule for each student by assigning them a time slot for each preferred subject. For each subject, choose the first available time slot from the predefined list that is also in the student’s available time slots and that is not already used by another subject in the student’s schedule. If no valid time slot can be found, the subject is added to an alert list.
The predefined available subject time slots are given by the following formula in LaTeX:
$$available\_subject\_time\_slots = \{\n\quad \text{Math}: [\text{Monday 9AM}, \text{Wednesday 10AM}],\n\quad \text{Science}: [\text{Monday 10AM}, \text{Thursday 11AM}],\n\quad \text{Literature}: [\text{Tuesday 9AM}, \text{Friday 10AM}],\n\quad \text{History}: [\text{Wednesday 9AM}, \text{Friday 11AM}]\n\}$$After scheduling, a series of queries will be provided. For each query, if the student exists, output their schedule in a structured format. Otherwise, indicate that no schedule was found.
inputFormat
The input is read from stdin and is formatted as follows:
- The first line contains an integer n representing the number of students.
- For each student, three lines are given:
- The student's name (a string).
- A space‐separated list of preferred subjects.
- A comma‐separated list of available time slots.
- After all student entries, there is a line with an integer q representing the number of queries, followed by q lines, each containing the name of a student whose schedule should be displayed.
outputFormat
The output is written to stdout. For each query, output the student's schedule. If the student exists, print:
Schedule for : Subject1: TimeSlot1 Subject2: TimeSlot2 ...
If there are subjects that could not be scheduled, append a line: Could not schedule: SubjectX, SubjectY, ...
If the student does not exist, print: Schedule not found for student: ## sample
3
Alice
Math Science Literature
Monday 9AM,Monday 10AM,Tuesday 9AM
Bob
Math History
Monday 9AM,Friday 11AM
Charlie
Science Literature History
Thursday 11AM,Tuesday 9AM,Friday 11AM
3
Alice
Bob
Charlie
Schedule for Alice:
Math: Monday 9AM
Science: Monday 10AM
Literature: Tuesday 9AM
Schedule for Bob:
Math: Monday 9AM
History: Friday 11AM
Schedule for Charlie:
Science: Thursday 11AM
Literature: Tuesday 9AM
History: Friday 11AM
</p>