CF555B.Case of Fugitive

普及+/提高

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Andrewid the Android is a galaxy-famous detective. He is now chasing a criminal hiding on the planet Oxa-5, the planet almost fully covered with water.

The only dry land there is an archipelago of n narrow islands located in a row. For more comfort let's represent them as non-intersecting segments on a straight line: island i has coordinates [l__i, r__i], besides, r__i < l__i + 1 for 1 ≤ i ≤ n - 1.

To reach the goal, Andrewid needs to place a bridge between each pair of adjacent islands. A bridge of length a can be placed between the i-th and the (i + 1)-th islads, if there are such coordinates of x and y, that l__i ≤ x ≤ r__i, l__i + 1 ≤ y ≤ r__i + 1 and y - x = a.

The detective was supplied with m bridges, each bridge can be used at most once. Help him determine whether the bridges he got are enough to connect each pair of adjacent islands.

安卓侦探安德鲁伊德是银河系闻名的侦探。他目前正在追捕一名藏匿在奥克萨-5星球上的罪犯,该星球几乎完全被水覆盖。

星球上唯一的陆地是一串排成一行的 nn 个狭长岛屿构成的群岛。为便于描述,我们将这些岛屿表示为一条直线上互不相交的线段:第 ii 个岛屿的坐标为 [li, ri][l_i,\,r_i],且对 1≤i≤n−11 \le i \le n-1,满足 ri<li+1r_i < l_{i+1}。

为达成目标,安德鲁伊德需在每一对相邻岛屿之间架设一座桥。长度为 aa 的桥可架设于第 ii 个岛屿与第 (i+1)(i+1) 个岛屿之间,当且仅当存在坐标 xx 和 yy,使得 li≤x≤ril_i \le x \le r_i,li+1≤y≤ri+1l_{i+1} \le y \le r_{i+1},且 y−x=ay - x = a。

侦探共获得 mm 座桥,每座桥最多只能使用一次。请帮助他判断所获得的桥是否足以连接每一对相邻岛屿。

输入格式

The first line contains integers n (2 ≤ n ≤ 2·105) and m (1 ≤ m ≤ 2·105) — the number of islands and bridges.

Next n lines each contain two integers l__i and r__i (1 ≤ l__i ≤ r__i ≤ 1018) — the coordinates of the island endpoints.

The last line contains m integer numbers _a_1, _a_2, ..., a__m (1 ≤ a__i ≤ 1018) — the lengths of the bridges that Andrewid got.

第一行包含两个整数 nn(2 ≤ n ≤ 2⋅1052 \leq n \leq 2\cdot10^5)和 mm(1 ≤ m ≤ 2⋅1051 \leq m \leq 2\cdot10^5)——分别表示岛屿的数量和桥梁的数量。

接下来的 nn 行,每行包含两个整数 lil_i 和 rir_i(1 ≤ li ≤ ri ≤ 10181 \leq l_i \leq r_i \leq 10^{18})——表示第 ii 座岛屿的左右端点坐标。

最后一行包含 mm 个整数 a1, a2, ..., ama_1,\,a_2,\,...,\,a_m(1 ≤ ai ≤ 10181 \leq a_i \leq 10^{18})——表示 Andrewid 所获得的桥梁的长度。

输出格式

If it is impossible to place a bridge between each pair of adjacent islands in the required manner, print on a single line "No" (without the quotes), otherwise print in the first line "Yes" (without the quotes), and in the second line print n - 1 numbers _b_1, _b_2, ..., b__n - 1, which mean that between islands i and i + 1 there must be used a bridge number b__i.

If there are multiple correct answers, print any of them. Note that in this problem it is necessary to print "Yes" and "No" in correct case.

如果无法按要求在每对相邻岛屿之间架设桥梁,则在一行中输出“No”(不含引号);否则,在第一行输出“Yes”(不含引号),在第二行输出 n−1n-1 个数 b1, b2, …, bn−1b_1,\,b_2,\,\dots,\,b_{n-1},表示在岛屿 ii 与 i+1i+1 之间必须使用编号为 bib_i 的桥梁。

若存在多个正确答案,输出任意一个即可。注意:本题中必须严格区分大小写地输出 “Yes” 和 “No”。

输入输出样例

  • 输入#1

    4 4
    1 4
    7 8
    9 10
    12 14
    4 5 3 8

    输出#1

    Yes
    2 3 1
  • 输入#2

    2 2
    11 14
    17 18
    2 9

    输出#2

    No
  • 输入#3

    2 1
    1 1
    1000000000000000000 1000000000000000000
    999999999999999999

    输出#3

    Yes
    1

说明/提示

In the first sample test you can, for example, place the second bridge between points 3 and 8, place the third bridge between points 7 and 10 and place the first bridge between points 10 and 14.

In the second sample test the first bridge is too short and the second bridge is too long, so the solution doesn't exist.

在第一个样例测试中,例如,你可以在点 3 和点 8 之间架设第二座桥,在点 7 和点 10 之间架设第三座桥,在点 10 和点 14 之间架设第一座桥。

在第二个样例测试中,第一座桥太短,第二座桥又太长,因此不存在可行解。

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

首页