Problem list
Log in
#coci00503 · COCI 2018/2019 Contest 2

Sunčanje

Diamond III 4.0 s 256 MB

Little Slavko dreamed of an unusual dream. One sunny morning, $N$ white rectangles climbed one by one on the rectangular roof of Slavko's house. They were preparing for an exotic trip to Hawaii - sunbathing. Each rectangle chose a place on the roof and lay in such a way that its sides were parallel to the edges of the roof. It is possible that some rectangles overlapped parts of other rectangles that have previously lain down on Slavko's roof. For each rectangle its length $A_{i}$, height $B_{i}$ and distances from the left and bottom edges of the roof, $X_{i}$ and $Y_{i}$, respectively, are known. After sunset, rectangles climbed down the roof and went to sleep dreaming of beautiful Hawaii beaches and their bodies tanned to yellow due to the sun exposure. However, the next morning they spotted a problem! Only parts of rectangles that had been directly exposed to the sun became yellow. In other words, if parts of a rectangle were covered by some other rectangle, then those parts didn't change colour from white to yellow. Sadly, rectangles that did not change the colour entirely were forced to cancel the trip. Write a program that will determine for each rectangle if it is going to Hawaii or not.

Input

The first line contains a positive integer $N$ ($1 \le N \le 100,000$), number of rectangles. Each of the next $N$ lines contains four integers $X_{i}$, $Y_{i}$ ($0 \le X_{i}$, $Y_{i} \le 10^{9}$), $A_{i}$ and $B_{i}$ ($1 \le A_{i}$, $B_{i} \le 10^{9}$), describing rectangles in the order they were climbing and lying down on the roof. $X_{i}$ represents distance from the left edge of the roof, $Y_{i}$ the distance from the bottom edge of the roof, $A_{i}$ the length and $B_{i}$ the height of the $i^{th}$ rectangle.

Output

You have to print $N$ lines. In $i^{th}$ line print “DA” (Croatian for yes, without quotation marks) if $i^{th}$ rectangle will go to Hawaii, otherwise print “NE” (Croatian for no).

Constraints

In test cases worth 10% of total points, it will hold that $N \le 10,000$.

Example 1

Input
5
1 1 4 2
6 1 1 1
2 2 2 3
3 4 3 2
4 0 1 2

3
3 3 1 1
2 2 3 3
1 1 5 5
Output
output
NE
DA
NE
DA
DA

NE
NE
DA

Clarification of the first sample: The first and the third rectangle are not entirely exposed to the sun, meaning they won’t change colour entirely and won’t go to Hawaii. Other rectangles are exposed to the sun entirely.

Source
COCI 2018/2019 Contest 2
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code