AT_arc231_c.One Sky, Many Stars

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

For length-NN sequences of non-negative integers x=(x1,x2,⋯ ,xN),d=(d1,d2,⋯ ,dN)x = (x_1, x_2, \cdots, x_N), d = (d_1, d_2, \cdots, d_N), consider the following problem Stargazing. Here, x1<x2<⋯<xNx_1 < x_2 < \cdots < x_N.

Stargazing
There are NN people numbered from 11 to NN on a number line. Person ii (1≤i≤N1 \leq i \leq N) is at coordinate xix_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 ii testifies that "the distance to the star nearest to me is did_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 NN people, and output Yes if it exists and No otherwise.

You are given length-NN sequences of non-negative integers A=(A1,A2,⋯ ,AN),B=(B1,B2,⋯ ,BN)A = (A_1, A_2, \cdots, A_N), B = (B_1, B_2, \cdots, B_N). Here, A1<A2<⋯<ANA_1 < A_2 < \cdots < A_N holds. Process QQ queries. The jj-th query (1≤j≤Q1 \leq j \leq Q) is represented as follows.

  • You are given an integer PjP_j between 11 and NN, inclusive, and a non-negative integer SjS_j. Change BPjB_{P_j} to SjS_j. Then, solve Stargazing with x,dx, d being A,BA, B, respectively. The change of BPjB_{P_j} carries over to subsequent queries.

Solve TT test cases per input file.

对于长度为 NN 的非负整数序列 x=(x1,x2,⋯ ,xN)x = (x_1, x_2, \cdots, x_N)、d=(d1,d2,⋯ ,dN)d = (d_1, d_2, \cdots, d_N),考虑如下问题 观星(Stargazing)。其中满足 x1<x2<⋯<xNx_1 < x_2 < \cdots < x_N。

观星(Stargazing)
数轴上有编号为 11 至 NN 的 NN 个人。第 ii 个人(1≤i≤N1 \leq i \leq N)位于坐标 xix_i 处。此外,数轴上还存在一个或多个“星星”,可视为点。
关于星星的排布,第 ii 个人声称:“离我最近的星星与我的距离为 did_i。” 当存在多个星星与该人距离同为最小值时,该声明仍视为成立。
判断是否存在一种星星排布方式,使得所有 NN 个人的陈述均不矛盾;若存在则输出 Yes,否则输出 No。

给定长度为 NN 的非负整数序列 A=(A1,A2,⋯ ,AN)A = (A_1, A_2, \cdots, A_N)、B=(B1,B2,⋯ ,BN)B = (B_1, B_2, \cdots, B_N),其中满足 A1<A2<⋯<ANA_1 < A_2 < \cdots < A_N。需处理 QQ 个查询。第 jj 个查询(1≤j≤Q1 \leq j \leq Q)的形式如下:

  • 给定一个整数 PjP_j(1≤Pj≤N1 \leq P_j \leq N)和一个非负整数 SjS_j,将 BPjB_{P_j} 修改为 SjS_j;然后以 x=Ax = A、d=Bd = B 作为输入求解 观星(Stargazing) 问题。对 BPjB_{P_j} 的修改将持续影响后续所有查询。

每组输入文件需处理 TT 个测试用例。

输入格式

The input is given from Standard Input in the following format. Here, casei\mathrm{case}_i (1≤i≤T1 \leq i \leq T) denotes the ii-th test case.

TT
case1\mathrm{case}_1
case2\mathrm{case}_2
⋮\vdots
caseT\mathrm{case}_T

Each test case is given in the following format:

NN
A1A_1 A2A_2 ⋯\cdots ANA_N
B1B_1 B2B_2 ⋯\cdots BNB_N
QQ
P1P_1 S1S_1
P2P_2 S2S_2
⋮\vdots
PQP_Q SQS_Q

输入从标准输入给出,格式如下。其中,casei\mathrm{case}_i(1≤i≤T1 \leq i \leq T)表示第 ii 个测试用例。

TT
case1\mathrm{case}_1
case2\mathrm{case}_2
⋮\vdots
caseT\mathrm{case}_T

每个测试用例的格式如下:

NN
A1A_1 A2A_2 ⋯\cdots ANA_N
B1B_1 B2B_2 ⋯\cdots BNB_N
QQ
P1P_1 S1S_1
P2P_2 S2S_2
⋮\vdots
PQP_Q SQS_Q

输出格式

Output the answers in the order case1,case2,⋯ ,caseT\mathrm{case}_1, \mathrm{case}_2, \cdots, \mathrm{case}_T. For each test case, output the answers to Stargazing for the 1,2,⋯ ,Q1, 2, \cdots, Q-th queries, separated by newlines.

按 case1,case2,⋯ ,caseT\mathrm{case}_1, \mathrm{case}_2, \cdots, \mathrm{case}_T 的顺序输出答案。对于每个测试用例,依次输出 Stargazing 问题中第 1,2,⋯ ,Q1, 2, \cdots, 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)A = (2, 4, 8), B = (3, 3, 0). The answer to Stargazing with x,dx, d being A,BA, B, respectively, is Yes. For example, if stars are at coordinates −1,7,8-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)A = (2, 4, 8), B = (7, 3, 0). The answer to Stargazing with x,dx, d being A,BA, 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≤101 \leq T \leq 10
  • 1≤N≤150 0001 \leq N \leq 150\,000
  • 0≤A1<A2<⋯<AN≤1090 \leq A_1 < A_2 < \cdots < A_N \leq 10^9
  • 0≤Bi≤1090 \leq B_i \leq 10^9 (1≤i≤N1 \leq i \leq N)
  • 1≤Q≤150 0001 \leq Q \leq 150\,000
  • 1≤Pj≤N1 \leq P_j \leq N (1≤j≤Q1 \leq j \leq Q)
  • 0≤Sj≤1090 \leq S_j \leq 10^9 (1≤j≤Q1 \leq j \leq Q)
  • The sum of NN over the TT test cases is at most 200 000200\,000.
  • The sum of QQ over the TT test cases is at most 200 000200\,000.
  • All input values are integers.

样例 1 解释:
对于第一个测试用例,每次查询的过程如下:

  • 第一次查询执行修改后,A=(2,4,8), B=(3,3,0)A = (2, 4, 8),\ B = (3, 3, 0)。此时以 x=Ax = A、d=Bd = B 作为输入调用 Stargazing 问题,答案为 Yes。例如,若恒星位于坐标 −1, 7, 8-1,\ 7,\ 8(如下图所示),则所有条件均被满足。
  • 第二次查询执行修改后,A=(2,4,8), B=(7,3,0)A = (2, 4, 8),\ B = (7, 3, 0)。此时以 x=Ax = A、d=Bd = B 作为输入调用 Stargazing 问题,答案为 No。这是因为可以证明:不存在任何恒星排布方式满足全部条件。

约束条件

  • 1≤T≤101 \leq T \leq 10
  • 1≤N≤150 0001 \leq N \leq 150\,000
  • 0≤A1<A2<⋯<AN≤1090 \leq A_1 < A_2 < \cdots < A_N \leq 10^9
  • 0≤Bi≤1090 \leq B_i \leq 10^9(1≤i≤N1 \leq i \leq N)
  • 1≤Q≤150 0001 \leq Q \leq 150\,000
  • 1≤Pj≤N1 \leq P_j \leq N(1≤j≤Q1 \leq j \leq Q)
  • 0≤Sj≤1090 \leq S_j \leq 10^9(1≤j≤Q1 \leq j \leq Q)
  • 所有 TT 个测试用例的 NN 值之和不超过 200 000200\,000。
  • 所有 TT 个测试用例的 QQ 值之和不超过 200 000200\,000。
  • 所有输入值均为整数。

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

首页