A9896 | Case of Fugitive
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 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.
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.
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
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.
In the second sample test the first bridge is too short and the second bridge is too long, so the solution doesn't exist.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted