Making a Timetable with 22 Credits
InterviewTime limit1sMemory limit1024 MB
Count the ways to pick at most one course per group so that no two chosen courses overlap in time and the credits total exactly 22.
- Level
Medium4 of 10
- Topics
- Backtracking, Brute force, Intervals
- Solved
- No attempts yet
Problem
Chansol plans to take 22 credits this semester. To build a timetable, Chansol grouped the courses to be taken as follows.
- Group A:
[전공종합설계1(가), 전공종합설계2(나), 컴퓨터공학특강1] - Group B:
[네트워크프로그래밍(가), 네트워크프로그래밍(나)] - Group C:
[멀티미디어응용] - Group D:
[SW융합세미나1, 정보기술세미나1] - Group E:
[파일처리(가), 파일처리(나)] - Group F:
[디지털공학(나), 디지털공학(다)] - Group G:
[문제해결] - Group H:
[프로그래밍언어(가)]
From each group, select at most one course to build the timetable. You do not have to pick a course from every group. A group may contain courses with different credit counts. Each course has a day of the week, a start time, and an end time, and selected courses must not overlap in time. Courses on different days do not overlap, and a course that ends at the moment another one starts does not overlap with it. Every course meets once a week, so all given courses are distinct.
Chansol wants to know how many timetables can be made in which the selected courses total exactly 22 credits.
Input
The first line contains the number of groups . From the second line on, each of the groups is described along with the courses it contains. The number of courses in a group comes first, followed by lines. Each of those lines gives the credits , the day , the start time , and the end time , separated by spaces. The start time and the end time are given in the HH:MM format, where HH is the hour and MM is the minute.
Output
Print the number of timetables that satisfy the conditions and whose selected courses total exactly 22 credits.
Constraints
00HH2300MM59- . A course never runs past midnight, and no course starts and ends at the same moment.
- All numbers in the input are integers.