302864: CF555B. Case of Fugitive
Memory Limit:256 MB
Time Limit:3 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Case of Fugitive
题意翻译
有$n$个区间,分别为$[l_i,r_i]$,$r_i<l_{i+1}$ 有$m$条线段,长度分别为$a_i$,当线段的两个端点分别在两个相邻的区间内是,线段可以连接这两个区间。 询问能否将所有区间联通。 ## 输入格式: 第一行两个正整数$n,m$,表示区间数和线段数。 接下来$n$行,每行两个正整数$l_i,r_i$,表示区间的左右端点。 接下来$1$行有$m$个正整数$a_i$,表示线段的长度。 ## 输出格式: 如果不能将所有区间联通,输出一行"No"。 否则在第一行输出"Yes",第二行输出$n-1$个正整数$b_i$,表示第$i$和第$i+1$个区间中用第$b_i$条线段连接。 ## 数据范围: $2\le n\le2\times10^5,1\le m\le2\times10^5$ $1\le l_i\le r_i\le10^{18},1\le a_i\le10^{18}$题目描述
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.输入输出格式
输入格式
The first line contains integers $ n $ ( $ 2<=n<=2·10^{5} $ ) and $ m $ ( $ 1<=m<=2·10^{5} $ ) — the number of islands and bridges. Next $ n $ lines each contain two integers $ l_{i} $ and $ r_{i} $ ( $ 1<=l_{i}<=r_{i}<=10^{18} $ ) — the coordinates of the island endpoints. The last line contains $ m $ integer numbers $ a_{1},a_{2},...,a_{m} $ ( $ 1<=a_{i}<=10^{18} $ ) — the lengths of the bridges that Andrewid got.
输出格式
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.
输入输出样例
输入样例 #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