CF160E.Buses and People

提高+/省选-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The main Bertown street is represented by a straight line. There are 109 bus stops located on the line. The stops are numbered with integers from 1 to 109 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 < 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 < 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.

伯顿市的主干道是一条直线。这条直线上共有 10910^9 个公交站,按道路顺序从 11 到 10910^9 编号。该市共有 nn 辆公交车。每天,第 ii 辆公交车从第 sis_i 号站驶向第 fif_i 号站(其中 si<fis_i < f_i),途中在所有中间站点停靠,且仅在夜间返回。该公交车于时刻 tit_i 出发,行驶速度极快,因此也在同一时刻 tit_i 到达终点。所有公交车的出发时刻 tit_i 互不相同。每辆公交车的载客量无限。

伯顿市共有 mm 名市民。今天,第 ii 名市民需从第 lil_i 号站前往第 rir_i 号站(其中 li<ril_i < r_i);该市民于时刻 bib_i 抵达其起始站(即第 lil_i 号站)。每位市民一方面希望尽快抵达目的地,另一方面坚决不愿在行程中换乘。更准确地说:第 ii 名市民选择满足以下条件的编号为 jj 的公交车,且其出发时刻 tjt_j 在所有满足条件的公交车中最小:

  • sj≤lis_j \leq l_i,
  • ri≤fjr_i \leq f_j,
  • bi≤tjb_i \leq t_j。

你的任务是:对每位市民,判断他今天是否能乘车抵达目的地;若可以,则输出他所乘坐的公交车编号。

输入格式

The first line contains two integers n and m (1 ≤ n, m ≤ 105) — 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 ≤ 109, s__i < 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 ≤ 109, l__i < r__i) — the Bertown citizens' description. Some b__i-s could coincide.

第一行包含两个整数 nn 和 mm(1≤n,m≤1051 \leq n, m \leq 10^5)—— 分别表示公交车的数量和人数。

接下来是 nn 行,每行包含三个整数:sis_i、fif_i、tit_i(1≤si,fi,ti≤1091 \leq s_i, f_i, t_i \leq 10^9,且 si<fis_i < f_i)—— 描述第 ii 辆公交车。保证所有 tit_i 互不相同。

接下来是 mm 行,每行包含三个整数:lil_i、rir_i、bib_i(1≤li,ri,bi≤1091 \leq l_i, r_i, b_i \leq 10^9,且 li<ril_i < r_i)—— 描述第 ii 位贝尔镇市民的信息。某些 bib_i 可能相同。

输出格式

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.

第一行输出 $ m $ 个用空格分隔的整数:第 $ i $ 个数应为 −1-1(若第 $ i $ 个人无法到达目的地),或为运送第 $ i $ 个人的公交车编号。公交车按输入顺序编号为 $ 1 $ 至 $ n $。

输入输出样例

  • 输入#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

输入解题思路,AI测评打分。不知道怎么写?

首页