Serogi's Perogis

View as PDF

Submit solution

Points: 7
Time limit: 1.2s
Memory limit: 32M

Author:
Problem type

As we all know, Serog1sPerog1s is filthy rich. Whether it's from tutoring chess or winning bets with Mr. Fraschetti, it's no doubt that he's drowning in John A. Macdonald's and Queen Elizabeth's. And true to his name, it comes off as no surprise that he blows all of his hard earned cash on perogis, to fuel his unearthly addiction (next to reloading TeachAssist of course).

One night, Serog1sPerog1s runs up to you in a panic, and tells you that his arch-nemesis EgorGor tripped him while he was walking home from the store, flinging the perogies he was holding all around the area. However, there's only one street light in the area, and due to the limitations I've created in this fictional world to facilitate the coherence of this problem, only perogies under that lamp's circle of light can be seen by the naked eye.

Serog1sPerog1s needs you to find the number of perogis that can be seen under the street light. But he reminds you that Serogi's Perogis are special; they are rectangles that come in various sizes, and will always be aligned with the x and y axis (nice realistic problem sankeeth that definetely makes sense). Any perogi that touches any point in the circle of light should be counted as seen.

Input Specification

The first line of the input will contain 3 integers denoting the x, y, and radius of the circle of light.

The second line will contain an integer n , the number of perogies dropped.

The next n lines will contain 4 integers denoting the x, y, (of the bottom-left corner), width, and height of each perogi.

Constraints

1 \le x, y, r, n, w, h\le 10^5

Output Specification

The number of perogis that can be seen under the light.

Sample Input

9 6 3
7
9 10 8 5
6 9 8 4
8 4 7 9
6 7 3 10
3 6 1 2
9 10 3 9
2 9 4 9

Sample Output

3

Comments

There are no comments at the moment.