AT_arc231_c.One Sky, Many Stars
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
For length-N sequences of non-negative integers x=(x1,x2,⋯,xN),d=(d1,d2,⋯,dN), consider the following problem Stargazing. Here, x1<x2<⋯<xN.
Stargazing
There are N people numbered from 1 to N on a number line. Person i (1≤i≤N) is at coordinate xi. 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 di." 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.
You are given length-N sequences of non-negative integers A=(A1,A2,⋯,AN),B=(B1,B2,⋯,BN). Here, A1<A2<⋯<AN holds. Process Q queries. The j-th query (1≤j≤Q) is represented as follows.
- You are given an integer Pj between 1 and N, inclusive, and a non-negative integer Sj. Change BPj to Sj. Then, solve Stargazing with x,d being A,B, respectively. The change of BPj carries over to subsequent queries.
Solve T test cases per input file.
对于长度为 N 的非负整数序列 x=(x1,x2,⋯,xN)、d=(d1,d2,⋯,dN),考虑如下问题 观星(Stargazing)。其中满足 x1<x2<⋯<xN。
观星(Stargazing)
数轴上有编号为 1 至 N 的 N 个人。第 i 个人(1≤i≤N)位于坐标 xi 处。此外,数轴上还存在一个或多个“星星”,可视为点。
关于星星的排布,第 i 个人声称:“离我最近的星星与我的距离为 di。” 当存在多个星星与该人距离同为最小值时,该声明仍视为成立。
判断是否存在一种星星排布方式,使得所有 N 个人的陈述均不矛盾;若存在则输出Yes,否则输出No。
给定长度为 N 的非负整数序列 A=(A1,A2,⋯,AN)、B=(B1,B2,⋯,BN),其中满足 A1<A2<⋯<AN。需处理 Q 个查询。第 j 个查询(1≤j≤Q)的形式如下:
- 给定一个整数 Pj(1≤Pj≤N)和一个非负整数 Sj,将 BPj 修改为 Sj;然后以 x=A、d=B 作为输入求解 观星(Stargazing) 问题。对 BPj 的修改将持续影响后续所有查询。
每组输入文件需处理 T 个测试用例。
输入格式
The input is given from Standard Input in the following format. Here, casei (1≤i≤T) denotes the i-th test case.
T
case1
case2
⋮
caseT
Each test case is given in the following format:
N
A1 A2 ⋯ AN
B1 B2 ⋯ BN
Q
P1 S1
P2 S2
⋮
PQ SQ
输入从标准输入给出,格式如下。其中,casei(1≤i≤T)表示第 i 个测试用例。
T
case1
case2
⋮
caseT
每个测试用例的格式如下:
N
A1 A2 ⋯ AN
B1 B2 ⋯ BN
Q
P1 S1
P2 S2
⋮
PQ SQ
输出格式
Output the answers in the order case1,case2,⋯,caseT. For each test case, output the answers to Stargazing for the 1,2,⋯,Q-th queries, separated by newlines.
按 case1,case2,⋯,caseT 的顺序输出答案。对于每个测试用例,依次输出 Stargazing 问题中第 1,2,⋯,Q 个查询的答案,各答案之间用换行符分隔。
输入输出样例
输入#1
2 3 2 4 8 3 1 0 2 2 3 1 7 1 0 0 1 1 1
输出#1
Yes No Yes
说明/提示
Sample 1 Explanation:
For the first test case, each query goes as follows.
- After the change in the first query, A=(2,4,8),B=(3,3,0). The answer to Stargazing with x,d being A,B, respectively, is
Yes. For example, if stars are at coordinates −1,7,8 as in the figure below, the conditions are satisfied. - After the change in the second query, A=(2,4,8),B=(7,3,0). The answer to Stargazing with x,d being A,B, respectively, is
No. This is because it can be shown that there exists no arrangement of the stars satisfying the conditions.

Constraints
- 1≤T≤10
- 1≤N≤150000
- 0≤A1<A2<⋯<AN≤109
- 0≤Bi≤109 (1≤i≤N)
- 1≤Q≤150000
- 1≤Pj≤N (1≤j≤Q)
- 0≤Sj≤109 (1≤j≤Q)
- The sum of N over the T test cases is at most 200000.
- The sum of Q over the T test cases is at most 200000.
- All input values are integers.
样例 1 解释:
对于第一个测试用例,每次查询的过程如下:
- 第一次查询执行修改后,A=(2,4,8), B=(3,3,0)。此时以 x=A、d=B 作为输入调用 Stargazing 问题,答案为
Yes。例如,若恒星位于坐标 −1, 7, 8(如下图所示),则所有条件均被满足。 - 第二次查询执行修改后,A=(2,4,8), B=(7,3,0)。此时以 x=A、d=B 作为输入调用 Stargazing 问题,答案为
No。这是因为可以证明:不存在任何恒星排布方式满足全部条件。

约束条件
- 1≤T≤10
- 1≤N≤150000
- 0≤A1<A2<⋯<AN≤109
- 0≤Bi≤109(1≤i≤N)
- 1≤Q≤150000
- 1≤Pj≤N(1≤j≤Q)
- 0≤Sj≤109(1≤j≤Q)
- 所有 T 个测试用例的 N 值之和不超过 200000。
- 所有 T 个测试用例的 Q 值之和不超过 200000。
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?