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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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.

Output
Output the total number of units of glitter placed on the cards.
Sample Input 1
5 6
1 2 3
15 5
2 2 3 5 5
1 3 3
2 2 3 3 3
2 2 3 5 5
Sample Output 1
7
Sample Input 2
4 4
1 3 2
1 4 3
2 1 1 2 4
2 1 1 4 2
Sample Output 2
1
Transcribed Image Text:Output Output the total number of units of glitter placed on the cards. Sample Input 1 5 6 1 2 3 15 5 2 2 3 5 5 1 3 3 2 2 3 3 3 2 2 3 5 5 Sample Output 1 7 Sample Input 2 4 4 1 3 2 1 4 3 2 1 1 2 4 2 1 1 4 2 Sample Output 2 1
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY