#K92987. Faculty Course Scheduling
Faculty Course Scheduling
Faculty Course Scheduling
You are tasked with developing an application that helps a university manage its course scheduling such that no faculty member is assigned overlapping teaching sessions. Each test case provides a list of courses with a faculty name, a start time, and an end time. Your program must determine for each test case whether it is possible to schedule the courses without any conflicts.
If a conflict exists (i.e. if a faculty member is assigned two courses such that the start time of one is less than the ending time of a previous course), output No
for that test case. Otherwise, output Yes
on the first line followed by the schedule details for each faculty member. For each faculty, print the faculty name followed by the scheduled time intervals (each interval represented by a start and an end time) on the same line. The intervals for each faculty must be displayed in ascending order according to their start times.
The condition for a conflict in mathematical (LaTeX) terms is: if a faculty member has sorted intervals \(I_1, I_2, \dots, I_k\) with \(I_i = [s_i, e_i]\), then the schedule is conflict-free if and only if \(s_{i+1} \ge e_i\) for every \(1 \le i < k\).
inputFormat
The input consists of multiple test cases. Each test case starts with an integer N representing the number of courses. The next N lines each contain a faculty name followed by two integers denoting the start and end times of a course. The input terminates with a test case where N is 0.
outputFormat
For each test case, if no scheduling conflicts occur, print "Yes" on the first line. Then, for each faculty member (sorted alphabetically), print a line containing the faculty name followed by the scheduled time intervals (start and end times). If any conflict is found for a test case, output "No" for that test case.## sample
3
alice 9 12
bob 10 13
alice 12 14
0
Yes
alice 9 12 12 14
bob 10 13
</p>