Journey among Railway Stations
时间限制:C/C++ 3秒,其他语言6秒
空间限制:C/C++ 524288K,其他语言1048576K
Articles
There are railway stations lying on a straight line, numbered from to . A strange thing is, each railway station only opens for a continuous period of time every day. In other words, if a train arrives before time or after time , it can not stop at station .
Many trains travel through these stations every day. It takes times for each train to travel from station to station with the top speed.
If a train driver wants to stop at station where the train may arrive early, he can choose to run slowly to meet the time requirements of that station. However, there is no way out if the train arrives late even with the top speed.
A new day is coming. As a train driver, now your train is at station , plan to leave for station at time , and stop at all stations of along the railway line. You are wondering whether your train can meet the arrival time requirements of all railway stations from to (boarding and alighting time at each station are ignored).
days are coming, one of the following three events will happen every day.
- Ask whether you can stop the train among each station .
- The railway line between station and station has been repaired and the passing time is changed to . i.e., set .
- Station change its open time to . i.e., set .
Please answer each question of the first type.
Input
The first line of the input contains an integer , indicating the number of test cases.
For each test case:
The first line contains a integer , indicating the number of stations. The second and third line contains intergers each, indicating the sequence and .The fourth line contains integers, indicating the sequence
The fifth line contains a integer . The next lines describe the event every day.
: ask whether you can stop the train among each station .
: change to a new value .
: the open time of station is changed to .
It’s guaranteed that the sum of over all test cases does not exceed .
Ouput
For each test case, output the answer for each question of the first type: Output ‘Yes’ if you can stop the train successfully, otherwise ‘No’.
Example
input
1 | 1 |
ouput
1 | Yes |
Tutorial
为开始时间, 为截止时间, 为执行花费时间.
新定义如下两种变量
若对于任意的 都满足 ,则表示可以按顺序完成所有事件。
上述判断和修改操作均可用线段树维护。(分治,合并时判断前断最大的 是否小于等于后断最小的 )
本题中第 个站点的开启时间相当于 ,第 个站点的关闭时间相当于 , 第 个站点到第 个站点的花费时间相当于 。
Code
1 |
|