CF1401E.Divide Square
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:384MB
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.
在坐标平面上有一个边长为 106×106 的正方形,其四个顶点分别为 (0,0)、(0,106)、(106,0) 和 (106,106)。
你将在该平面上绘制若干线段。所有线段均为水平或垂直方向,且每条线段至少与正方形的一条边相交。
现在你想知道:在绘制完所有线段后,该正方形被分成了多少个区域?请编写一个程序计算正方形被分割出的区域数量。
输入格式
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.
第一行包含两个整数 n 和 m(0≤n,m≤105),分别表示水平线段的数量和垂直线段的数量。
接下来的 n 行描述水平线段。第 i 行包含三个整数 yi、lxi 和 rxi(0<yi<106;0≤lxi<rxi≤106),表示该线段连接点 (lxi,yi) 和 (rxi,yi)。
接下来的 m 行描述垂直线段。第 i 行包含三个整数 xi、lyi 和 ryi(0<xi<106;0≤lyi<ryi≤106),表示该线段连接点 (xi,lyi) 和 (xi,ryi)。
保证不存在两条线段位于同一条直线上,且每条线段至少与正方形的一条边相交。
输出格式
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:

示例图如下:

输入解题思路,AI测评打分。不知道怎么写?