#P5861. Student Group Assignment
Student Group Assignment
Student Group Assignment
There are \(N\) students numbered from \(0\) to \(N-1\). Every day, the teacher has several projects that must be completed by groups of students, and each project requires a group of a specific size. For each project with required group size \(s\), the teacher needs to form a group of exactly \(s\) students.
Each student \(i\) is willing to work only in a group whose size is between \(A_i\) and \(B_i\) (inclusive). Additionally, each student can be assigned to at most one group per day, and some students may not join any group. Each group is assigned to only one project.
The teacher has already decided the projects for the next \(Q\) days. For every day, given the list of projects and their required group sizes, determine if there is an assignment of students to projects such that each project has a complete group whose size exactly matches the project requirement and every student in that group finds the group size acceptable.
Note: All formulas are provided in \(\LaTeX\) format.
inputFormat
The input begins with an integer \(N\) (the number of students). The next \(N\) lines each contain two integers \(A_i\) and \(B_i\), indicating that student \(i\) is willing to work in groups whose sizes are between \(A_i\) and \(B_i\) (inclusive).
The following line contains an integer \(Q\) representing the number of days. For each day, there is a line starting with an integer \(M\) (the number of projects on that day), followed by \(M\) integers, each denoting the required group size for a project.
outputFormat
Output \(Q\) lines. For each day, output Yes
if there exists an assignment of students to projects such that every project has a complete group meeting the requirements; otherwise, output No
.
sample
3
1 2
1 3
2 3
2
1 2
2 1 2
Yes
Yes
</p>