一片天空,繁星点点AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)For length-$N$ sequences of non-negative integers $x = (x_1, x_2, \cdots, x_N), d = (d_1, d_2, \cdots, d_N)$, consider the following problem Stargazing. Here, $x_1 < x_2 < \cdots < x_N$.
对于长度为 $N$ 的非负整数序列 $x = (x_1, x_2, \cdots, x_N), d = (d_1, d_2, \cdots, d_N)$,考虑以下问题 观星。其中,$x_1 < x_2 < \cdots < x_N$。AI (CI翻译)
Stargazing There are
$N$people numbered from$1$to$N$on a number line. Person$i$($1 \leq i \leq N$) is at coordinate$x_i$. Also, there are one or more stars on the number line, which can be regarded as points. Regarding the arrangement of the stars, person$i$testifies that "the distance to the star nearest to me is$d_i$." There may be multiple stars at the minimum distance from the person. Determine whether there exists an arrangement of the stars that does not contradict the testimonies of the$N$people, and outputYesif it exists andNootherwise.
AI (CI翻译)观星 数轴上有
$N$个人,编号为$1$到$N$。人$i$($1 \leq i \leq N$)位于坐标$x_i$。此外,数轴上有一颗或多颗星星,它们可以看作点。 对于星星的分布情况,人$i$作证称:“离我最近的星星与我的距离是$d_i$。”离这个人最近的星星可能不止一颗。 判断是否存在一种星星的分布情况,使得$N$个人的证词均不矛盾。如果存在,输出Yes;否则输出No。
You are given length-$N$ sequences of non-negative integers $A = (A_1, A_2, \cdots, A_N), B = (B_1, B_2, \cdots, B_N)$. Here, $A_1 < A_2 < \cdots < A_N$ holds. Process $Q$ queries. The $j$-th query ($1 \leq j \leq Q$) is represented as follows.
给定长度为 $N$ 的非负整数序列 $A = (A_1, A_2, \cdots, A_N), B = (B_1, B_2, \cdots, B_N)$。其中,$A_1 < A_2 < \cdots < A_N$。请处理 $Q$ 次询问。第 $j$ 次询问($1 \leq j \leq Q$)如下所示:AI (CI翻译)
- You are given an integer
$P_j$between$1$and$N$, inclusive, and a non-negative integer$S_j$. Change$B_{P_j}$to$S_j$. Then, solve Stargazing with$x, d$being$A, B$, respectively. The change of$B_{P_j}$carries over to subsequent queries.
- 给定一个介于
$1$和$N$(含)之间的整数$P_j$,以及一个非负整数$S_j$。将$B_{P_j}$修改为$S_j$,然后令$x, d$分别为$A, B$,求解观星问题。对$B_{P_j}$的修改会保留,并影响后续询问。
Solve $T$ test cases per input file.
每个输入文件包含 $T$ 组测试用例。请分别求解。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$1 \leq T \leq 10$$1 \leq N \leq 150\,000$$0 \leq A_1 < A_2 < \cdots < A_N \leq 10^9$$0 \leq B_i \leq 10^9$($1 \leq i \leq N$)$1 \leq Q \leq 150\,000$$1 \leq P_j \leq N$($1 \leq j \leq Q$)$0 \leq S_j \leq 10^9$($1 \leq j \leq Q$)- The sum of
$N$over the$T$test cases is at most$200\,000$. - The sum of
$Q$over the$T$test cases is at most$200\,000$. - All input values are integers.
$1 \leq T \leq 10$$1 \leq N \leq 150\,000$$0 \leq A_1 < A_2 < \cdots < A_N \leq 10^9$$0 \leq B_i \leq 10^9$($1 \leq i \leq N$)$1 \leq Q \leq 150\,000$$1 \leq P_j \leq N$($1 \leq j \leq Q$)$0 \leq S_j \leq 10^9$($1 \leq j \leq Q$)- 所有测试用例的
$N$之和不超过$200\,000$。 - 所有测试用例的
$Q$之和不超过$200\,000$。 - 所有输入值均为整数。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format. Here, $\mathrm{case}_i$ ($1 \leq i \leq T$) denotes the $i$-th test case.
输入从标准输入读入,格式如下。其中,$\mathrm{case}_i$($1 \leq i \leq T$)表示第 $i$ 组测试用例。AI (CI翻译)
T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T
T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_TAI (CI翻译)
Each test case is given in the following format:
每组测试用例的格式如下:AI (CI翻译)
N
A_1 A_2 \cdots A_N
B_1 B_2 \cdots B_N
Q
P_1 S_1
P_2 S_2
\vdots
P_Q S_Q
N
A_1 A_2 \cdots A_N
B_1 B_2 \cdots B_N
Q
P_1 S_1
P_2 S_2
\vdots
P_Q S_QAI (CI翻译)
Output
输出格式
AI (CI翻译)Output the answers in the order $\mathrm{case}_1, \mathrm{case}_2, \cdots, \mathrm{case}_T$. For each test case, output the answers to Stargazing for the $1, 2, \cdots, Q$-th queries, separated by newlines.
按照 $\mathrm{case}_1, \mathrm{case}_2, \cdots, \mathrm{case}_T$ 的顺序输出答案。对于每组测试用例,按顺序输出第 $1, 2, \cdots, Q$ 次询问中观星问题的答案,每个答案占一行。AI (CI翻译)
样例
2
3
2 4 8
3 1 0
2
2 3
1 7
1
0
0
1
1 1
Yes
No
Yes
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。