Please code in python Kiki is making “Happy National Pizza Day” (February 9th) cards for all of her friends. She’s a bit disappointed with the cards not looking special enough, so she decides to add glitter to them to make them look more special. However, she’s short on glitter, so she decides to add glitter selectively. She uses a box with N*N divided sections to store her cards. Each section is huge and each card is small, so she can put multiple cards in a g
Please code in python
Kiki is making “Happy National Pizza Day” (February 9th) cards for all of her friends. She’s a bit disappointed with the cards not looking special enough, so she decides to add glitter to them to make them look more special. However, she’s short on glitter, so she decides to add glitter selectively.
She uses a box with N*N divided sections to store her cards. Each section is huge and each card is small, so she can put multiple cards in a given section and they will never overlap. We model the way that she organizes the cards and adds glitter using two commands:
- Command 1: 1 x y: add a card to the box in section (x, y).
- Command n: 2 x1 y1 x2 y2: Add one unit of glitter to each of the cards in the sections from (x1, y2) to (x2, y2).
Help Kiki determine the total number of units of glitter that she placed on the cards.
Input
The first line will contain N (1 <= N <= 500) and C (1 <= C <= 500 ), the square size of the card storage box and the number of commands.
The next C lines will contain one of the commands listed above.
Command 1 will contain x (1 <= x <= N) and y (1 <= y <= N), the coordinates where a new card will be added.
Command 2 will contain x1, y1, x2, and y2 (1 < = x1 <= x2 <= N, 1 < = y1 < = y2 <= N), a rectangle of sections where one unit of glitter is added to all the cards.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images