Codeforces Round 483 (Div. 1) [Thanks, Botan Investments and Victor Shaburov!]
D
Arkady and Rectangles
Codeforces
3300
原题
← CE →
翻译中…

Arkady has got an infinite plane painted in color $0$. Then he draws $n$ rectangles filled with paint with sides parallel to the Cartesian coordinate axes, one after another. The color of the $i$-th rectangle is $i$ (rectangles are enumerated from $1$ to $n$ in the order he draws them). It is possible that new rectangles cover some of the previous ones completely or partially.

翻译中…

Count the number of different colors on the plane after Arkady draws all the rectangles.

翻译中…

Input

翻译中…

The first line contains a single integer $n$ ($1 \le n \le 100\,000$) — the number of rectangles.

翻译中…

The $i$-th of the next $n$ lines contains $4$ integers $x_1$, $y_1$, $x_2$ and $y_2$ ($-10^9 \le x_1 \lt x_2 \le 10^9$, $-10^9 \le y_1 \lt y_2 \le 10^9$) — the coordinates of corners of the $i$-th rectangle.

翻译中…

Output

翻译中…

In the single line print the number of different colors in the plane, including color $0$.

翻译中…

Note

翻译中…

image That's how the plane looks in the first sampleimage That's how the plane looks in the second sample$0$ = white, $1$ = cyan, $2$ = blue, $3$ = purple, $4$ = yellow, $5$ = red.

翻译中…

样例

Input #1
5
-1 -1 1 1
-4 0 0 4
0 0 4 4
-4 -4 0 0
0 -4 4 0
Output #1
5
InputCopy OutputCopy
Input #2
4
0 0 4 4
-4 -4 0 0
0 -4 4 0
-2 -4 2 4
Output #2
5
InputCopy OutputCopy
题目信息
题号
983D
时间限制
4 s
内存限制
256 MB
标签
数据结构

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。