Cafeteria Vendor

All submissions for this problem are available.
Cafeteria Vendor!
 There is exactly one batch for each flavor of milkshake, and it is either malted or unmalted.
 For each employee, vendor makes at least one milkshake type that they like.
 The minimum possible number of batches are malted.
Input file sample
2 5 3 1 1 1 2 1 0 2 0 1 5 0 1 2 1 1 0 1 1 1
Input
 One line containing the integer N, the number of milkshake flavors.
 One line containing the integer M, the number of employees.
 M lines, one for each employee, each containing:
 An integer T ≥ 1, the number of milkshake types the employee likes, followed by
 T pairs of integers "X Y", one for each type the employee likes, where X is the milkshake flavor between 1 and N inclusive, and Y is either 0 to indicate unmalted, or 1 to indicated malted.
Note that:
 No pair will occur more than once for a single employee.
 Each employee will have at least one flavor that they like (T ≥ 1).
 Each employee will like at most one malted flavor. (At most one pair for each customer has Y = 1).
Output sample
Case #1: YES 1 0 0 0 0 Case #2: IMPOSSIBLE TO SATISFY ALL
Output
 C lines, one for each test case in the order they occur in the input file, each containing the string "Case #X: " where X is the number of the test case, starting from 1, followed by:
 The string "IMPOSSIBLE TO SATISFY ALL", if the employees' preferences cannot be satisfied; OR
 YES followed by a space then N spaceseparated integers, one for each flavor from 1 to N, which are 0 if the corresponding flavor should be prepared unmalted, and 1 if it should be malted.
Constraints
C ≤ 100 1 ≤ N ≤ 10 1 ≤ M ≤ 100 The sum of all the T values for the customers in a test case will not exceed 3000.
Explanation of the sample
The second employee is satisfied by getting flavor #2 unmalted, and the third employee is satisfied by getting flavor #5 unmalted.
In the second case, there is only one flavor. One of the employees wants it malted and one wants it unmalted. You cannot satisfy them both.
Author:  sujay173 
Tags  sujay173 
Date Added:  22092016 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions