#K8386. Course Enrollment Schedule Conflict Check
Course Enrollment Schedule Conflict Check
Course Enrollment Schedule Conflict Check
You are given the number of students n, the number of courses m, and the enrollment details for each course. Each course detail consists of three parts: the course number, the time slot in which the course takes place, and a comma-separated list of student names enrolled in that course.
Your task is to determine whether all students can be enrolled in their desired courses without any schedule conflicts. A schedule conflict occurs if a student is enrolled in two courses that occur at the same time slot.
If no conflicts are found, output Yes; otherwise, output No.
The problem can be formalized mathematically as following: Let \(S\) be the set of students, and for each student \(s \in S\), let \(T_s\) denote the set of time slots in which the student is enrolled. The enrollment is conflict-free if and only if for every student \(s\), all elements in \(T_s\) are distinct. In other words, \(\forall s \in S,\ |T_s| = \text{number of courses student } s \text{ enrolled in}\).
inputFormat
The input is given via stdin and has the following format:
n m course_number1 time_slot1 students_list1 course_number2 time_slot2 students_list2 ... course_numberm time_slotm students_listm
Here, the first line contains two integers: n is the number of students and m is the number of courses. The next m lines each describe a course. Each course description consists of an integer course number, an integer time slot, and a string of student names separated by commas (with no spaces in between). If no student is enrolled in a course, the student list will be empty.
outputFormat
The output should be printed to stdout as a single line:
Yes
if all students can be enrolled without any conflicts, or
No
if there exists at least one scheduling conflict.
## sample3 2
1 1 Alice,Bob
2 2 Alice,Charlie
Yes