CF1401E.Divide Square
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There is a square of size 106×106 on the coordinate plane with four points (0,0) , (0,106) , (106,0) , and (106,106) as its vertices.
You are going to draw segments on the plane. All segments are either horizontal or vertical and intersect with at least one side of the square.
Now you are wondering how many pieces this square divides into after drawing all segments. Write a program calculating the number of pieces of the square.
输入格式
The first line contains two integers n and m ( 0≤n,m≤105 ) — the number of horizontal segments and the number of vertical segments.
The next n lines contain descriptions of the horizontal segments. The i -th line contains three integers yi , lxi and rxi ( 0<yi<106 ; 0≤lxi<rxi≤106 ), which means the segment connects (lxi,yi) and (rxi,yi) .
The next m lines contain descriptions of the vertical segments. The i -th line contains three integers xi , lyi and ryi ( 0<xi<106 ; 0≤lyi<ryi≤106 ), which means the segment connects (xi,lyi) and (xi,ryi) .
It's guaranteed that there are no two segments on the same line, and each segment intersects with at least one of square's sides.
输出格式
Print the number of pieces the square is divided into after drawing all the segments.
输入输出样例
输入#1
3 3 2 3 1000000 4 0 4 3 0 1000000 4 0 1 2 0 5 3 1 1000000
输出#1
7
说明/提示
The sample is like this: