D. Distinct Characters Queries

该博客讨论如何解决一种字符串查询问题,其中涉及替换字符和计算给定子串中不同字符的数量。作者建议使用线段树,并通过位运算来维护每个节点的字符集合,以高效地进行区间查询和修改。在每种类型的查询中,对给定子串的唯一字符计数是关键。
摘要由CSDN通过智能技术生成

You are given a string s consisting of lowercase Latin letters and q

queries for this string.

Recall that the substring s[l;r]

of the string s is the string slsl+1…sr

. For example, the substrings of "codeforces" are "code", "force", "f", "for", but not "coder" and "top".

There are two types of queries:

  • 1 pos c

(1≤pos≤|s|, c is lowercase Latin letter): replace spos with c (set spos:=c

  • );
  • 2 l r

(1≤l≤r≤|s|): calculate the number of distinct characters in the substring s[l;r]

Input

The first line of the input contains one string s

consisting of no more than 105

lowercase Latin letters.

The second line of the input contains one integer q

(1≤q≤105

) — the number of queries.

The next q

lines contain queries, one per line. Each query is given in the format

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值