CF286D.Tourists
省选/NOI-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A double tourist path, located at a park in Ultima Thule, is working by the following principle:
- We introduce the Cartesian coordinate system.
- At some points of time there are two tourists going (for a walk) from points ( - 1, 0) and (1, 0) simultaneously. The first one is walking from ( - 1, 0), the second one is walking from (1, 0).
- Both tourists in a pair move at the same speed 1 (distance unit per second), the first one moves along line x = - 1, the second one moves along line x = 1, both of them are moving in the positive direction of the Oy axis.
- At some points of time walls appear. Wall (l__i, r__i) is a segment between points (0, l__i) and (0, r__i). Each wall appears immediately.
The Ultima Thule government wants to learn this for each pair of tourists that walk simultaneously: for how long (in seconds) will they not see each other? Two tourists don't see each other if the segment that connects their positions on the plane intersects at least one wall. Two segments intersect if they share at least one point. We assume that the segments' ends belong to the segments.
Help the government count the required time. Note that the walls can intersect (in any way) or coincide.
位于终极之地(Ultima Thule)某公园内的双游客路径按如下规则运行:
- 我们引入笛卡尔坐标系。
- 在某些时刻,有两名游客分别从点 (−1,0) 和 (1,0) 同时出发(散步)。第一位游客从 (−1,0) 出发,第二位游客从 (1,0) 出发。
- 每一对同时出发的游客均以相同的速度 1(单位距离/秒)移动:第一位游客沿直线 x=−1 移动,第二位游客沿直线 x=1 移动;两人都沿 Oy 轴正方向移动。
- 在某些时刻会出现墙壁。墙壁 (li,ri) 是连接点 (0,li) 与 (0,ri) 的线段。每堵墙壁均立即出现。
终极之地政府希望对每一对同时出发的游客,计算出他们彼此“看不见”的持续时间(单位:秒)。当连接两名游客当前位置的线段与至少一堵墙壁相交时,他们便彼此看不见。两条线段相交,当且仅当它们至少有一个公共点。我们约定:线段的端点属于该线段。
请协助政府计算所要求的时间。注意:墙壁之间可以以任意方式相交,甚至可以重合。
输入格式
The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 105) — the number of pairs of tourists and the number of built walls. The next m lines contain three space-separated integers l__i, r__i and t__i each (0 ≤ l__i < r__i ≤ 109, 0 ≤ t__i ≤ 109) — the wall ends and the time it appeared. The last line contains n distinct space-separated strictly increasing integers _q_1, _q_2, ..., q__n (0 ≤ q__i ≤ 109) — the points of time when pairs of tourists walk.
All points of time are given in seconds.
第一行包含两个以空格分隔的整数 n 和 m(1≤n,m≤105)—— 分别表示游客对的数量和已建造的墙的数量。
接下来的 m 行每行包含三个以空格分隔的整数 li、ri 和 ti(0≤li<ri≤109,0≤ti≤109)—— 分别表示第 i 面墙的左右端点及其出现时间。
最后一行包含 n 个互不相同、严格递增的以空格分隔的整数 q1,q2,…,qn(0≤qi≤109)—— 表示各对游客行走的时间点。
所有时间点均以秒为单位给出。
输出格式
For each pair of tourists print on a single line a single integer — the time in seconds when the two tourists from the corresponding pair won't see each other. Print the numbers in the order in which the they go in the input.
对于每一对游客,在一行中输出一个整数——即该对游客彼此无法看见对方的时间(单位:秒)。请按照输入中给出的顺序输出这些数值。
输入输出样例
输入#1
2 2 1 4 3 3 6 5 0 1
输出#1
2 4
输入#2
3 3 0 3 4 0 1 2 2 4 0 1 3 4
输出#2
2 4 4
输入解题思路,AI测评打分。不知道怎么写?