410086: GYM103940 C Correcting School Enrollment Errors

Memory Limit:1024 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Correcting School Enrollment Errorstime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard output

Planet E-13 orbits around a star in a faraway galaxy named UAZ. In that planet, everyone attends the same super powerful university, which has the capacity to receive up to $$$N$$$ students per semester. Every student gets a school ID, and at the beginning of each semester, each of the students request to enroll in up to eight courses. School enrollment applications are registered by the secretary of the school department, however, given that sometimes she must do it very quickly because the deadlines are very close, students could end up enrolled in courses that they did not request and/or they could have courses they requested to be enrolled in but they were not. Given the list of students with their course requests, and the list of courses in which they actually ended up enrolled in the school system, your job is to provide a list of changes to be made to the school system's records, so that effectively the students end up enrolled in each and every one of the courses they requested, without having missing or unrequested courses.

Input

In the first line of input there will be two integers $$$N$$$ and $$$M$$$ $$$(1 \leq N, M \leq 10^5)$$$, the number of students requesting at least one course enrollment this semester and the number of students that got at least one course enrollment this semester, respectively.

The next $$$N$$$ lines, start with two integers $$$A$$$ $$$(1 \leq A \leq 10^7)$$$ and $$$B$$$ $$$(1 \leq B \leq 8)$$$, the ID of the student and the number of class enrollments student $$$A$$$ is requesting respectively. Then in the same line will be $$$B$$$ integers $$$b_i$$$ $$$(1 \leq b_i \leq 10^4)$$$, this are the enrollment requests by student $$$A$$$.

The next $$$M$$$ lines, start with two integers $$$A$$$ $$$(1 \leq A \leq 10^7)$$$ and $$$C$$$ $$$(1 \leq C \leq 8)$$$, the ID of the student and the number of class enrollments student $$$A$$$ received. Then in the same line will be $$$C$$$ integers $$$c_i$$$ $$$(1 \leq c_i \leq 10^4)$$$, this are the enrollments assigned to the student $$$A$$$ by the school.

note: students and enrollment lists will appear in any order.

Output

If there was no error in enrollments, you should print "GREAT WORK! NO MISTAKES FOUND!" in one line, without quotes.

Otherwise you need to print the changes needed in enrollment such that all students get exactly the courses they requested, not more, not less.

For each student that needs a change in their enrollment there will be a line: the ID of the student followed by a list of corrections separated by spaces, a correction is of type $$$-m$$$ or $$$+m$$$, which are removing a course and adding a course respectively, the list should be printed ordered in ascending order of the absolute value of $$$m$$$. The ID's of students should appear in ascending order, also corrections should be ordered in ascending order for each student. Once all of the changes are listed (ordered by student ID and course ID), you should print the text "MISTAKES IN X STUDENTS: Y NOT REQUESTED, Z MISSED" (without the quotes) replacing X for the number of students that had mistakes in the system, Y for the total number of course enrollments registered in the system that were not requested by the students and Z for the total number of course enrollments that were requested but were not in the system

ExamplesInput
3 3
1 4 5 4 2 10
4 3 1 2 11
3 2 9 2
4 3 1 2 11
1 4 5 4 2 10
3 2 9 2
Output
GREAT WORK! NO MISTAKES FOUND!
Input
3 5
5 3 9 8 1
9 2 8 7
4 1 10
3 2 1 3
5 4 9 1 4 2
1 4 2 3 1 5
2 3 9 8 2
8 3 2 4 5
Output
1 -1 -2 -3 -5
2 -2 -8 -9
3 -1 -3
4 +10
5 -2 -4 +8
8 -2 -4 -5
9 +7 +8
MISTAKES IN 7 STUDENTS: 14 NOT REQUESTED, 4 MISSED

加入题单

上一题 下一题 算法标签: