1. 程式人生 > >牛客網暑期ACM多校訓練營(第六場)I Team Rocket

牛客網暑期ACM多校訓練營(第六場)I Team Rocket

then ica for each oar bject www 訓練營 line subject

題目鏈接: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