#P4416. [COCI2017-2018#1] Plahte
[COCI2017-2018#1] Plahte
题目描述
Little Donald decided to wash all N of his white sheets one day. After washing them, he put them to dry on the ground in his backyard. Donald placed the sheets so that ** none of them touch on the tips or the sides and that none of their sides intersect**, but it is possible that he placed smaller sheets on top of bigger ones, or that a sheet is completely covering another sheet. After doing this, Donald went to bed.
Donald’s friend Kim somehow got the information that Donald is drying his sheets and decided to mess with him. He found a paintball gun from his father in the attic. Along with the gun, there were M paintball balls in different colours, but it is possible that there were more balls having the same colour. As soon as Donald fell asleep, Kim walked into his backyard and started shooting the sheets with his paintball gun. We all know that sheets bleed, so when Kim shoots the topmost sheet, that sheet would bleed the color of the ball down to all of the sheets beneath it. After Kim used all the balls, he happily left Donald’s backyard.
When Donald woke up and went to get his sheets, shock ensued. On most of Donald’s sheets, there was a number of new colours. Since Donald is very interested in correct data, and he’s in shock and not able to think, he is asking you to tell him the number of new colours on each sheet.
We can represent Donald’s backyard as an infinite coordinate system, and the sheets as rectangles parallel to the coordinate axes. Kim’s shots can be represented as points in that system.
Please note: it is possible that Kim’s shot missed all the sheets, but coordinates of each shot are unique.
输入格式
The first line of input contains the positive integers N (1 ≤ N ≤ 80 000), the number of sheets, and M (1 ≤ M ≤ 80 000), the number of paintball balls.
The of the following N lines contains four numbers: the coordinates of the lower left corner , (1 ≤ , ≤ ) and the upper right corner , , (1 ≤ , ≤ ) of the sheet.
The of the following M lines contains the coordinates where Kim’s shot landed , (1 ≤, ≤ ), and (1 ≤ ≤ ), the colour label of the ball.
输出格式
The of N lines must contain the number of new colours on the sheet.
题目大意
小唐纳德决定一天洗完他的白色床单。洗完后,他把它们放在后院的地上晾干。唐纳德把床单放在上面,使它们之间角或边不会互相接触,边也不会相交,但他可能把较小的床单放在大的上面,或者一个完全覆盖另个。做完这件事后,唐纳德上床睡觉了。
唐纳德的朋友基姆不知怎么地得到了唐纳德正在烘干他的床单的消息,决定和他捣乱。他在阁楼上找到了他父亲的彩弹枪。除了枪之外,还有不同颜色的彩弹球,但有可能有很多的球是相同的颜色。唐纳德一睡着,基姆走进他的后院,开始用他的彩弹枪射击床单。我们都知道床单会渗水,所以当基姆射出最上面的那张床单时,那张床单会把球的颜色渗到下面的所有床单上。基姆用了所有的球后,他愉快地离开了唐纳德的后院。
当唐纳德醒过来去拿床单时,非常震惊。在唐纳德的大部分床单上都有一些新的颜色。由于唐纳德对正确的数据很感兴趣,他太震惊了,以至于无法思考,他要求你告诉他每张床单上的新颜色的数量。
我们可以把唐纳德的后院表示成一个无限坐标系,而这些床单是平行于坐标轴的矩形。基姆的彩弹可以表示为该系统中的点。
请注意:基姆的彩弹可能没有打到任何一张床单,但是每一个彩弹的坐标都是独一无二的。
输入的第一行包含正整数床单的数量n(1≤n≤80000)和彩弹球数m(1≤m≤80000)。
接下来的n行中的每一行包含四个数字:表示左下角的坐标Ai,Bi(1≤Ai,Bi≤1000000000)和右上角的坐标Ci,Di(1 ≤Ci,Di≤1000000000)。
接下来的M行中的每一行包含三个数字,包含基姆投篮的坐标Xj,Yj(1≤Xj,Yj≤1000000000),第j个球的颜色Kj(1≤Kj≤1000000000)。
共n行,每一行必须包含在第i张床单上的新颜色的数量。
2 2
1 1 3 3
5 6 10 10
3 3 1
5 1 2
1
0
3 3
1 1 7 7
2 2 6 6
3 3 5 5
4 4 1
2 6 2
4 7 3
3
2
1
1 3
1 1 7 7
2 6 2
4 7 3
4 4 1
3