300839: CF160E. Buses and People

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Buses and People

题意翻译

## 题意 已知n辆公交车,有 $t_i,s_i,f_i$ 三个属性,表示在 $t_i$ 时刻从 $s_i$ 到达 $f_i$,途中可以任意上下车。 已知m个人,有 $l_i,r_i,b_i$ 三个属性,表示要在 $b_i$ 时刻及以后乘坐一辆公交车从 $l_i$ 到达 $r_i$。求 $t_i$ 最小的可行的公交车的编号。 更正式的说法:求 $i$ 使得 $b_i \leq t_i \space and \space s_i \leq l_i \space and \space r_i \leq f_i$ 且 $t_i$ 最小 ## 数据范围 $1 \leq n,m \leq 10^5$ $1 \leq t_i,s_i,f_i \leq 10^9$ $1 \leq l_i,r_i,b_i \leq 10^9$

题目描述

The main Bertown street is represented by a straight line. There are $ 10^{9} $ bus stops located on the line. The stops are numbered with integers from $ 1 $ to $ 10^{9} $ in the order in which they follow on the road. The city has $ n $ buses. Every day the $ i $ -th bus drives from stop number $ s_{i} $ to stop number $ f_{i} $ ( $ s_{i}&lt;f_{i} $ ), it stops on all intermediate stops and returns only at night. The bus starts driving at time $ t_{i} $ and drives so fast that it finishes driving also at time $ t_{i} $ . The time $ t_{i} $ is different for all buses. The buses have infinite capacity. Bertown has $ m $ citizens. Today the $ i $ -th person should get from stop number $ l_{i} $ to stop number $ r_{i} $ ( $ l_{i}&lt;r_{i} $ ); the $ i $ -th citizen comes to his initial stop ( $ l_{i} $ ) at time $ b_{i} $ . Each person, on the one hand, wants to get to the destination point as quickly as possible, and on the other hand, definitely does not want to change the buses as he rides. More formally: the $ i $ -th person chooses bus $ j $ , with minimum time $ t_{j} $ , such that $ s_{j}<=l_{i} $ , $ r_{i}<=f_{j} $ and $ b_{i}<=t_{j} $ . Your task is to determine for each citizen whether he can ride to the destination point today and if he can, find the number of the bus on which the citizen will ride.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ m $ ( $ 1<=n,m<=10^{5} $ ) — the number of buses and the number of people. Then $ n $ lines follow, each of them contains three integers: $ s_{i} $ , $ f_{i} $ , $ t_{i} $ ( $ 1<=s_{i},f_{i},t_{i}<=10^{9},s_{i}&lt;f_{i} $ ) — the description of the buses. It is guaranteed that all $ t_{i} $ -s are different. Then $ m $ lines follow, each of them contains three integers: $ l_{i} $ , $ r_{i} $ , $ b_{i} $ ( $ 1<=l_{i},r_{i},b_{i}<=10^{9},l_{i}&lt;r_{i} $ ) — the Bertown citizens' description. Some $ b_{i} $ -s could coincide.

输出格式


In the first line print $ m $ space-separated integers: the $ i $ -th number should be equal either to -1, if the person number $ i $ can't get to the destination point, or to the number of the bus that will ride the person number $ i $ . The buses are numbered with integers from $ 1 $ to $ n $ in the input order.

输入输出样例

输入样例 #1

4 3
1 10 10
5 6 2
6 7 3
5 7 4
5 7 1
1 2 1
1 10 11

输出样例 #1

4 1 -1

输入样例 #2

1 1
1 1000000000 1000000000
1 1000000000 1000000000

输出样例 #2

1

Input

题意翻译

## 题意 已知n辆公交车,有 $t_i,s_i,f_i$ 三个属性,表示在 $t_i$ 时刻从 $s_i$ 到达 $f_i$,途中可以任意上下车。 已知m个人,有 $l_i,r_i,b_i$ 三个属性,表示要在 $b_i$ 时刻及以后乘坐一辆公交车从 $l_i$ 到达 $r_i$。求 $t_i$ 最小的可行的公交车的编号。 更正式的说法:求 $i$ 使得 $b_i \leq t_i \space and \space s_i \leq l_i \space and \space r_i \leq f_i$ 且 $t_i$ 最小 ## 数据范围 $1 \leq n,m \leq 10^5$ $1 \leq t_i,s_i,f_i \leq 10^9$ $1 \leq l_i,r_i,b_i \leq 10^9$

加入题单

算法标签: