CF496E.Distributing Parts

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are an assistant director in a new musical play. The play consists of nn musical parts, each part must be performed by exactly one actor. After the casting the director chose mm actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.

First, each actor has a certain voice range and there are some parts that he cannot sing. Formally, there are two integers for each actor, cic_{i} and did_{i} ( ci<=dic_{i}<=d_{i} ) — the pitch of the lowest and the highest note that the actor can sing. There also are two integers for each part — aja_{j} and bjb_{j} ( aj<=bja_{j}<=b_{j} ) — the pitch of the lowest and the highest notes that are present in the part. The ii -th actor can perform the jj -th part if and only if ci<=aj<=bj<=dic_{i}<=a_{j}<=b_{j}<=d_{i} , i.e. each note of the part is in the actor's voice range.

According to the contract, the ii -th actor can perform at most kik_{i} parts. Besides, you are allowed not to give any part to some actors (then they take part in crowd scenes).

The rehearsal starts in two hours and you need to do the assignment quickly!

输入格式

The first line contains a single integer nn — the number of parts in the play ( 1n1051\le n \le 10^5 )

Next nn lines contain two space-separated integers each, aja_j and bjb_j — the range of notes for the jj-th part (1ajbj109)( 1\le a_j \le b_j \le 10^9 )

The next line contains a single integer mm—the number of actors (1m105)( 1\le m \le 10^5 )

Next mm lines contain three space-separated integers each ci,dic_i,d_i and kik_i,— the range of the ii-th actor and the number of parts that he can perform ( 1cidi1091\le c_i \le d_i \le 10^9,1ki1091\le k_i \le 10^9 )

输出格式

If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line.

In the next line print nn space-separated integers. The ii -th integer should be the number of the actor who should perform the ii -th part. If there are multiple correct assignments, print any of them.

If there is no correct assignment, print a single word "NO" (without the quotes).

输入输出样例

  • 输入#1

    3
    1 3
    2 4
    3 5
    2
    1 4 2
    2 5 1
    

    输出#1

    YES
    1 1 2
    
  • 输入#2

    3
    1 3
    2 4
    3 5
    2
    1 3 2
    2 5 1
    

    输出#2

    NO
    
首页