Building a timetable
Time limit1sMemory limit128 MB
For each student, count the courses whose every meeting period lies among that student's free periods.
- Level
Easy3 of 10
- Topics
- Bit manipulation, Brute force, Implementation
- Solved
- No attempts yet
Problem
Course registration has started. Students want to know which extra courses fit into the periods they still have free.
A course is a candidate for a student when every period in which the course meets is one of that student's free periods. For each student, count the candidate courses.
Only the count matters, so candidates that collide with each other are all counted. For example, if Monday periods 1, 2, 3, 4, 5 are free, one course meets on Monday periods 1, 2, 3, 4, and another meets on Monday periods 2, 3, 4, 5, then both courses are candidates.
Input
The first line contains the number of courses ().
Each of the next lines describes one course: the number of periods () in which it meets, followed by integers (), separated by spaces. Each is a period in which that course meets.
Period numbers run day by day. Monday periods 1 to 10 are 1 to 10, Tuesday periods 1 to 10 are 11 to 20, and by the same rule Friday period 10 is 50. For example, a course that meets on Tuesday periods 2 and 3 and on Wednesday periods 4 and 5 is given as 4 12 13 24 25.
The next line contains the number of students ().
Each of the next lines describes one student: the number of free periods (), followed by integers (), separated by spaces.
Output
For each student, in input order, print the number of candidate courses on its own line.