Submit | All submissions | Best solutions | Back to list |
HS08VCTN - Vacation Plans |
Julia is arranging the schedule of workers' vacation periods (leave) at her company in 2009. Company employees do not work on Saturdays, Sundays, on public holidays, and apart from this each employee must be on leave for a fixed number of working days of the year. We assume that in 2009 public holidays (not counting Saturdays and Sundays) are as follows: January 1, April 13, May 1, June 11, November 11, and December 25. All other days from Monday to Friday are working days.
Several preliminary vacation plans have already been prepared. Julia's task is now to see whether each of the plans is correct. In a valid plan, each employee will use exactly as many days of leave as he is entitled to, and on any given working day no more than 2 workers will be on vacation (so as not to disorganize the working of the office).
Input
First 3≤p<20, the number of plans, followed by 3≤n<20, the number of employees. The names of the employees are always two words of no more then 20 characters of the Latin alphabet. The names of all employees are different. In the following n lines, the first name and the last name of each employee and the number of their days off in 2009.
Then, for each plan, first a line of the form: Plan [No.], where [No.] is the plan number, followed by a description of the vacation plans of the employees:
[FirstName LastName] [number of holiday periods] [period1] [period2] ...
Vacation periods are describedin the format: [dd-mm:dd-mm], where the first date marks the first day of the holiday, and the second one - its last day.
Output
For each plan, print one line containing the word: OK if the plan meets the conditions of the problem, or the word ERROR in the opposite case.
Example
Input: 4 3 Julia Manifold 20 Robert Tensor 20 Adam Minor 20 Plan 1 Julia Manifold 1 20-06:19-07 Robert Tensor 1 20-06:19-07 Adam Minor 2 01-01:05-01 04-05:27-05 Plan 2 Robert Tensor 1 19-06:19-07 Julia Manifold 1 20-06:19-07 Adam Minor 2 01-01:05-01 04-05:27-05 Plan 3 Adam Minor 2 01-01:05-01 26-05:21-06 Julia Manifold 1 20-06:19-07 Robert Tensor 1 20-06:19-07 Plan 4 Julia Manifold 1 20-06:19-07 Robert Tensor 1 20-06:19-07 Adam Minor 2 01-01:05-01 27-05:22-06 Output: OK ERROR OK ERROR
Explanation: In the second plan Robert Tensor's leave is one working day too long. In the fourth plan there is a working day (June 22) on which more than two employees are out of the office.
Scoring
By solving this problem you score 10 points.
Added by: | kuszi |
Date: | 2008-11-22 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: CLOJURE NODEJS PERL6 VB.NET |
Resource: | High School Programming League 2008/2009 |