Advertisement
namchuai

Untitled

Feb 23rd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. 2
  2.  
  3. 5
  4. 3
  5. 1 1 1
  6. 2 1 0 2 0
  7. 1 5 0
  8.  
  9. 1
  10. 2
  11. 1 1 0
  12. 1 1 1
  13.  
  14.  
  15. Problem
  16.  
  17. You own a paint factory. Tehre are N different colors you can mix, and each color can be prepared "matte" or "glossy". So, you can make 2N different types of paint. Each of your customers has a set of paint types they like, and they will be satisfied if you have at least one of those types prepared.
  18.  
  19. =>>> At most one of the types a customer likes will be a "matte".
  20.  
  21. You want to make N batches of paint, so that:
  22.  
  23. =>>> There is exactly one batch for each color of paint, and it is either matte or glossy.
  24.  
  25. For each customer, you make at least one paint type that they like.
  26.  
  27. =>>> The minimum possible number of batches are matte (since matte is more expensive to make).
  28.  
  29. Find whether it is possible to satisfy all your customers given these constraints, and if it is, what paint types you should make. If it is possible to satisfy all your customers, there will be only one answer which minimizes the number of matte batches.
  30.  
  31. Input
  32.  
  33. One line containing an integer C, the number of test cases in the input file. For each test case, there will be: One line containing the integer N, the number of paint colors. One line containing the integer M, the number of customers. M lines, one for each customer, each containing: An integer T >= 1, the number of paint types the customer likes, followed by T pairs of integers "X Y", one for each type the customer likes, where X is the paint color between 1 and N inclusive, and Y is either 0 to indicate glossy, or 1 to indicated matte. Note that: No pair will occur more than once for a single customer. Each customer will have at least one color that they like (T >= 1). Each customer will like at most one matte color. (At most one pair for each customer has Y = 1). All of these numbers are separated by single spaces.
  34.  
  35. Output
  36.  
  37. 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", if the customers' preferences cannot be satisfied; OR N space-separated integers, one for each color from 1 to N, which are 0 if the corresponding paint should be prepared glossy, and 1 if it should be matte. Limits
  38.  
  39. Small dataset C = 100 1 <= N <= 10 1 <= M <= 100
  40.  
  41. Large dataset C = 5 1 <= N <= 2000 1 <= M <= 2000
  42.  
  43. The sum of all the T values for the customers in a test case will not exceed 3000. Sample
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement