AT_abc473_f.A/AB Insertion

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

You are given a string SS of length NN consisting of A and B.
Process a total of QQ queries of the following types.

1 ii cc

Type 11: Change the ii-th character of SS to cc.

2 ll rr

Type 22:
Let string TT be the string obtained by extracting the ll-th through rr-th characters of the current string SS.
If it is possible to obtain string TT by the following operation, output Yes; otherwise, output No.

  • Starting from the empty string, perform the following two operations any number of times, possibly zero, in any order.
    • Choose any position in the string (possibly the beginning or the end) and insert A there.
    • Choose any position in the string (possibly the beginning or the end) and insert AB there.

给你一个长度为 NN 的字符串 SS,其字符仅由 A 和 B 组成。
你需要处理总共 QQ 个如下类型的查询。

1 ii cc

类型 1:将字符串 SS 的第 ii 个字符修改为 cc。

2 ll rr

类型 2:
令字符串 TT 为当前字符串 SS 中从第 ll 个字符到第 rr 个字符(含)所构成的子串。
若字符串 TT 可通过以下操作得到,则输出 Yes;否则输出 No。

  • 从空字符串出发,可任意次数(包括零次)、以任意顺序执行以下两种操作:
    • 在字符串的任意位置(可以是开头或结尾)插入字符 A;
    • 在字符串的任意位置(可以是开头或结尾)插入字符串 AB。

输入格式

The input is given from Standard Input in the following format:

NN
SS
QQ
Query1{\rm Query}_1
Query2{\rm Query}_2
⋮\vdots
QueryQ{\rm Query}_Q

Here, Queryi{\rm Query}_i represents the ii-th query, and the input format for a query follows the format described in the problem statement.

输入从标准输入中按以下格式给出:

NN
SS
QQ
Query1{\rm Query}_1
Query2{\rm Query}_2
⋮\vdots
QueryQ{\rm Query}_Q

其中,Queryi{\rm Query}_i 表示第 ii 个查询,每个查询的输入格式遵循题目描述中所规定的格式。

输出格式

Each time a query of type 22 is given, output the answer on one line.

每次给出类型为 22 的查询时,在一行中输出答案。

输入输出样例

  • 输入#1

    10
    AABBAABABB
    6
    2 1 10
    1 5 B
    2 1 10
    2 6 8
    1 3 A
    2 1 10

    输出#1

    Yes
    No
    Yes
    Yes

说明/提示

Sample 1 Explanation:
This input contains six queries.

  • Initially, S=S= AABBAABABB.
  • For the 11-st query, T=T= AABBAABABB, obtained by extracting the 11-st through 1010-th characters of SS, can be obtained by the following steps, so output Yes.
    • Start from the empty string.
    • Insert AB at the beginning of the empty string, making the string AB.
    • Insert AB right after the 11-st character of AB, making the string AABB.
    • Insert AB at the end of AABB, making the string AABBAB.
    • Insert AB right after the 55-th character of AABBAB, making the string AABBAABB.
    • Insert AB right after the 77-th character of AABBAABB, making the string AABBAABABB.
  • For the 22-nd query, change the 55-th character of SS to B. As a result, S=S= AABBBABABB.
  • For the 33-rd query, T=T= AABBBABABB, obtained by extracting the 11-st through 1010-th characters of SS, cannot be obtained by the operation described in the problem statement, so output No.
  • For the 44-th query, T=T= ABA, obtained by extracting the 66-th through 88-th characters of SS, can be obtained by the operation described in the problem statement, so output Yes.
  • For the 55-th query, change the 33-rd character of SS to A. As a result, S=S= AAABBABABB.
  • For the 66-th query, T=T= AAABBABABB, obtained by extracting the 11-st through 1010-th characters of SS, can be obtained by the operation described in the problem statement, so output Yes.

Constraints

  • NN is an integer satisfying 1≤N≤5×1051 \le N \le 5 \times 10^5.
  • SS is a string of length NN consisting of A and B.
  • QQ is an integer satisfying 1≤Q≤2×1051 \le Q \le 2 \times 10^5.
  • Each given query is of type 11 or 22.
  • Queries of type 11 satisfy the following constraints:
    • ii is an integer satisfying 1≤i≤N1 \le i \le N, and
    • cc is A or B.
  • Queries of type 22 satisfy the following constraints:
    • ll and rr are integers satisfying 1≤l≤r≤N1 \le l \le r \le N.

样例 1 解释:
该输入包含六个查询。

  • 初始时,S=S= AABBAABABB。
  • 对于第 11 个查询,T=T= AABBAABABB(通过提取 SS 的第 11 至第 1010 个字符得到),可通过以下步骤构造,因此输出 Yes:
    • 从空字符串开始;
    • 在空字符串开头插入 AB,得到字符串 AB;
    • 在 AB 的第 11 个字符后插入 AB,得到字符串 AABB;
    • 在 AABB 末尾插入 AB,得到字符串 AABBAB;
    • 在 AABBAB 的第 55 个字符后插入 AB,得到字符串 AABBAABB;
    • 在 AABBAABB 的第 77 个字符后插入 AB,得到字符串 AABBAABABB。
  • 对于第 22 个查询,将 SS 的第 55 个字符修改为 B,于是 S=S= AABBBABABB。
  • 对于第 33 个查询,T=T= AABBBABABB(通过提取 SS 的第 11 至第 1010 个字符得到),无法通过题目描述的操作构造,因此输出 No。
  • 对于第 44 个查询,T=T= ABA(通过提取 SS 的第 66 至第 88 个字符得到),可由题目描述的操作构造,因此输出 Yes。
  • 对于第 55 个查询,将 SS 的第 33 个字符修改为 A,于是 S=S= AAABBABABB。
  • 对于第 66 个查询,T=T= AAABBABABB(通过提取 SS 的第 11 至第 1010 个字符得到),可由题目描述的操作构造,因此输出 Yes。

约束条件

  • NN 是满足 1≤N≤5×1051 \le N \le 5 \times 10^5 的整数。
  • SS 是一个长度为 NN、仅由字符 A 和 B 组成的字符串。
  • QQ 是满足 1≤Q≤2×1051 \le Q \le 2 \times 10^5 的整数。
  • 每个给定查询的类型为 11 或 22。
  • 类型 11 的查询满足以下约束:
    • ii 是满足 1≤i≤N1 \le i \le N 的整数;
    • cc 为 A 或 B。
  • 类型 22 的查询满足以下约束:
    • ll 和 rr 是满足 1≤l≤r≤N1 \le l \le r \le N 的整数。

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

首页