## SAC '22 Code Challenge 2 P2 - Cookie Sprinkler

View as PDF

Points: 5
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

To help build a new home for Mr. DeMello Santa, you were tasked with maintaining a 2D, tank of milk in his house.

In this tank, you will be asked to perform queries of types:

1 x y: Add one new cookie to the tank of milk at position .

2 x1 y1 x2 y2: Add sprinkles to all the cookies once in the rectangle from to .

Can you help Santa determine the sum of the sprinkles placed on the cookies?

#### Input Specification

The first line will contain and , the square size of the milk tank and the number of queries.

The next lines will contain one of the queries listed above.

For type queries, they will contain and , the coordinates of the new cookie.

For type queries, they will contain , , , and , a rectangle where all cookies are given one more sprinkle.

Note: One cell can contain multiple cookies.

#### Output Specification

Output the sum of the sprinkles placed on the cookies.

#### Sample Input

6 6
1 2 3
1 5 6
2 2 3 5 6
1 4 4
2 2 3 4 4
2 2 3 5 6

#### Sample Output

7

#### Explanation for Sample Output

In all the queries, the cookie at is sprinkled times, the cookie at is sprinkled times, and the cookie at is sprinkled times.