Question: 2 . Paint Ball Amrita is a budding painter. One evening, she took some white drawing sheets, placed them on a table in her garden
Paint Ball Amrita is a budding painter. One evening, she took some white drawing sheets, placed them on a table in her garden and went to her room to get her painting brushes. It so happened that while some sheets lay on top of other sheets, none of the sheet borders intersected. Sheru, Amrita's mischievous younger brother had just returned from a paintball game and decided to have some fun with his sister's sheets. He used his paint pistol and fired paint balls of different colors at the sheets.Due to the force of the gun, once a paint ball hit a sheet, the ball's color spread to all of the sheets beneath it After using all the balls, he ran away from the garden, hoping no one would notice him. When Amrita returned with the brushes, she was shocked to see the paint blots on the sheets. She wanted to know if there were any good sheets left to use or not, and therefore started counting how many colors were spread on each sheet. Can you write a program to help her? Amrita's table is represented as an endless coordinate system, with the sheets as rectangles parallel to the coordinate axes. Sheru's shots are represented as points on the coordinate system. Do keep in mind that Sheru's shots may not have touched all of the sheets, and each shot was in a different position. The colors are represented using integers as labels. Read the input from STDIN and print the output to STDOUT. Do not print arbitrary strings anywhere in the program, as these contribute to the standard output and test cases will fail. Input Format: The first line of input contains the positive integersNthe number of drawing sheets, andMthe number of paint balls. The nextNlinescontain four numbers: the coordinates of the lowerleft cornerPi,Qiand the upper right cornerRi,Siof theithpainting sheet. The nextMlinescontain three numbers: the coordinatesXj,Yjwhere Sheru's shots landed, andKj, the color label of thejthball. Output Format: The output must printNlines, one for each sheet, each containing the number of colors on theithsheet. Constraints: N M PiQi RiSi XjYj Kj Sample Input: Sample Output: Explanation: Here, the total number of painting sheetsNis andthe number of ballsMis also First Sheet is spread from to Second Sheet is spread from to Third Sheet is spread from to Ball of color hit at Ball of color hit at Ball of color hit at The below diagram depicts how the sheets were placed and where the paint balls hit. We can see that sheet consists of only color, sheet consists of different colors, and sheet consists of only color. Hence and are printed as output, each in a new line. Sample Input: Sample Output: Explanation: There are sheets and color balls. First Sheet is spread from to Second Sheet is spread from to Color ball hit at Color ball hit at Color ball hit at Color ball hit at So the above diagram depicts that since color is not touching any of the sheets, it will not be counted. Sheet consists of different colors, and sheet consists of only color.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
