Logo
(追記) (追記ここまで)

24581번 - Even Substrings 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
7 초 (추가 시간 없음) 1024 MB61292151.220%

문제

You are given a string s[1..n] consisting of the first 6 lowercase English letters between a and f. A substring is called even if every distinct letter in it appears an even number of times. For example, in abbacac there are 4 even substrings: abba, bb, acac, bbacac. If a same substring appears at different locations, they shall be counted multiple times, e.g. the string aaa has 2 even substrings aa.

You are to process q queries of the following two types:

  1. Given a range specified by two integers l and r, count the number of even substrings in s[l..r], the substring of s starting at s[l] and ending at s[r] (both ends are inclusive).
  2. Given an index i and a letter x between a and f, change s[i] to x.

입력

The first line of input has a single string s[1..n] (1 ≤ n ≤ 2 · 105) consisting of letters between a and f.

The second line of input has a single integer q (1 ≤ q ≤ 2 · 105), the number of queries. Each of the next q lines gives one query:

  • Type 1 query has 1 l r (1 ≤ l ≤ r ≤ n).
  • Type 2 query has 2 i x (1 ≤ i ≤ n), where x is a letter between a and f.

There is at least one query of type 1.

출력

For each type 1 query output the number of even substrings on a single line.

제한

예제 입력 1

abbacac
8
1 1 7
2 5 a
1 4 6
1 1 7
2 6 b
1 2 6
1 5 7
1 1 1

예제 출력 1

4
2
6
4
0
0

힌트

출처

ICPC > Regionals > North America > Mid-Atlantic Regional > 2021 Mid-Atlantic USA Regional Contest E번

ICPC > Regionals > North America > North Central North America Regional > 2021 North Central NA Regional Contest A번

  • 문제를 만든 사람: Bowen Yu
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /