首页 > 其他 > 详细

牛客网暑期ACM多校训练营(第六场)I Team Rocket

时间:2018-09-12 22:01:04      阅读:243      评论:0      收藏:0      [点我收藏+]

题目链接:https://www.nowcoder.com/acm/contest/144/I

时间限制:C/C++ 4秒,其他语言8秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld

题目描述 

There are n trains running between Kanto and Johto region. Assuming the railway is a number line, the i-th train travels from coordinate li to coordinate ri (both inclusive).

One day, m Team Rocket members invaded the railway system successfully. The i-th Team Rocket member was going to destroy the transportation hub with coordinate xi. Once a transportation hub within the driving range of a train is destroyed, the train‘s itinerary will be canceled immediately.

Giovanni wants to know how many train trips will be firstly canceled after each attack.

After all the attacks finished, for each train Giovanni needs to know that in which attack its itinerary was firstly canceled, or it was unaffected at all.

输入描述:

The input starts with one line containing exactly one integer T, which is the number of test cases.

For each test case, the first line contains two integers n and m, indicating the number of trains and the number of Team Rocket members.

Each of the next n lines contains 2 integers li and ri, indicating the driving range of the i-th train.

Each of the next m lines contains exactly one integer yi. 
技术分享图片, where xi is the transportation hub that Team Rocket members would destroy in the i-th attack, resi-1 is the product of the indexes of trips cancelled by the (i-1)-th attack and  技术分享图片 means exclusive or. 

If no such trip exists, resi-1 is considered to be 0.

- 1 ≤ T ≤ 5.
- 1 ≤ n,m ≤ 2 x 105.
- -109 ≤ li ≤ ri ≤ 109.
- -109 ≤ xi ≤ 109.

输出描述:

For each test case, output one line "Case #x:" first, where x is the test case number (starting from 1).

Then output m lines, each line of which contains exactly one integer, indicating the number of train trips firstly canceled after the i-th attack.

Finally output one line, containing n integers, where the i-th integer is the time when the i-th train trip is firstly canceled or 0 if it is not affected.
示例1

输入

复制
1
3 4
1 3
2 6
-999 1000000000
-1000
1
5
2

输出

复制
Case #1:
0
2
1
0
2 3 2

题意:现在有n列火车,每列火车有自己的运营区间[L,R],现在有m个黑客,每个黑客攻击一个位置Xi,问每次攻击之后有几个火车停止运营,以及每列火车是在第几次攻击之后停止运营的,如果列车线路之间
包括攻击点Xi,那么该火车就停止运营。还有就是下一次攻击的节点是由上一次攻击结束之后得到的,也就是防止离线操作的。
思路:首先将该题简化,题意也就是说有n个区间[L,R],每次找到一个点,将包含该点的区间全部删除,找到每次操作之后有多少个区间收到影响,还需要记录一下每个区间在第几次操作之后被删除的。

牛客网暑期ACM多校训练营(第六场)I Team Rocket

原文:https://www.cnblogs.com/Flower-Z/p/9637590.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!