CF160E.Buses and People

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

The main Bertown street is represented by a straight line. There are 10910^{9} bus stops located on the line. The stops are numbered with integers from 11 to 10910^{9} in the order in which they follow on the road. The city has nn buses. Every day the ii -th bus drives from stop number sis_{i} to stop number fif_{i} ( s_{i}<f_{i} ), it stops on all intermediate stops and returns only at night. The bus starts driving at time tit_{i} and drives so fast that it finishes driving also at time tit_{i} . The time tit_{i} is different for all buses. The buses have infinite capacity.

Bertown has mm citizens. Today the ii -th person should get from stop number lil_{i} to stop number rir_{i} ( l_{i}<r_{i} ); the ii -th citizen comes to his initial stop ( lil_{i} ) at time bib_{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 ii -th person chooses bus jj , with minimum time tjt_{j} , such that sj<=lis_{j}<=l_{i} , ri<=fjr_{i}<=f_{j} and bi<=tjb_{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 nn and mm ( 1<=n,m<=1051<=n,m<=10^{5} ) — the number of buses and the number of people.

Then nn lines follow, each of them contains three integers: sis_{i} , fif_{i} , tit_{i} ( 1<=s_{i},f_{i},t_{i}<=10^{9},s_{i}<f_{i} ) — the description of the buses. It is guaranteed that all tit_{i} -s are different.

Then mm lines follow, each of them contains three integers: lil_{i} , rir_{i} , bib_{i} ( 1<=l_{i},r_{i},b_{i}<=10^{9},l_{i}<r_{i} ) — the Bertown citizens' description. Some bib_{i} -s could coincide.

输出格式

In the first line print mm space-separated integers: the ii -th number should be equal either to -1, if the person number ii can't get to the destination point, or to the number of the bus that will ride the person number ii . The buses are numbered with integers from 11 to nn 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
    
首页