CF496E.Distributing Parts

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m 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, c__i and d__i (c__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 — a__j and b__j (a__j ≤ b__j) — the pitch of the lowest and the highest notes that are present in the part. The i-th actor can perform the j-th part if and only if c__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 i-th actor can perform at most k__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!

你是一部新音乐剧的助理导演。该剧包含 nn 个音乐段落,每个段落必须由恰好一名演员演唱。在完成选角后,导演已选定 mm 名可参与演出的演员。你的任务是将这些段落分配给演员。然而,存在若干限制条件。

首先,每名演员都有特定的音域,因此无法演唱某些段落。形式化地,对第 ii 名演员,给定两个整数 cic_i 和 did_i(满足 ci≤dic_i \leq d_i),分别表示该演员能演唱的最低音高和最高音高;对第 jj 个段落,也给定两个整数 aja_j 和 bjb_j(满足 aj≤bja_j \leq b_j),分别表示该段落中出现的最低音高和最高音高。当且仅当 ci≤aj≤bj≤dic_i \leq a_j \leq b_j \leq d_i 时,第 ii 名演员才能演唱第 jj 个段落,即该段落中所有音高均落在该演员的音域范围内。

根据合同约定,第 ii 名演员最多可演唱 kik_i 个段落。此外,允许不为某些演员分配任何段落(此时他们仅参与群演场面)。

排练将在两小时后开始,你必须迅速完成分配!

输入格式

The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105).

Next n lines contain two space-separated integers each, a__j and b__j — the range of notes for the j-th part (1 ≤ a__j ≤ b__j ≤ 109).

The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105).

Next m lines contain three space-separated integers each, c__i, d__i and k__i — the range of the i-th actor and the number of parts that he can perform (1 ≤ c__i ≤ d__i ≤ 109, 1 ≤ k__i ≤ 109).

第一行包含一个整数 nn —— 剧本中的部分数量(1 ≤ n ≤ 1051 ≤ n ≤ 10^5)。

接下来的 nn 行,每行包含两个以空格分隔的整数 aja_j 和 bjb_j —— 第 jj 个部分所需的音符范围(1 ≤ aj ≤ bj ≤ 1091 ≤ a_j ≤ b_j ≤ 10^9)。

下一行包含一个整数 mm —— 演员数量(1 ≤ m ≤ 1051 ≤ m ≤ 10^5)。

接下来的 mm 行,每行包含三个以空格分隔的整数 cic_i、did_i 和 kik_i —— 第 ii 个演员所能演唱的音符范围及其最多可承担的部分数量(1 ≤ ci ≤ di ≤ 1091 ≤ c_i ≤ d_i ≤ 10^9,1 ≤ ki ≤ 1091 ≤ k_i ≤ 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 n space-separated integers. The i-th integer should be the number of the actor who should perform the i-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).

如果存在一个满足上述所有条件的分配方案,则在第一行输出单个单词 “YES”(不带引号)。

在下一行输出 n 个用空格分隔的整数。其中第 i 个整数表示应由哪位演员来出演第 i 个角色。若存在多个正确的分配方案,输出任意一个即可。

如果不存在正确的分配方案,则输出单个单词 “NO”(不带引号)。

输入输出样例

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

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

首页