PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000046. Tiến hóa ADN
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tiến hóa ADN
DNA Evolution
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A DNA string contains only A, T, G, C. Process events:
1 x c: replace character at position withc.2 l r e: repeat non-empty pattern infinitely as , aligning its first character with position . Count positions for which .
This counts individual matching positions under a periodic alignment, not the number of substring occurrences of . The pattern length is at most .
Input
The first line contains the DNA string, the second contains , followed by lines of either 1 x c or 2 l r e.
Output
Output the number of matching positions for every type-2 query.
Subtasks
- Subtask 1 (15 points): ; ; Pattern has length between and .
- Subtask 2 (20 points): ; ; Pattern has length between and .
- Subtask 3 (25 points): ; ; Pattern has length between and .
- Subtask 4 (40 points): ; ; Pattern has length between and .
Examples
Input
ATGCATGC
4
2 1 8 ATGC
2 2 6 TTT
1 4 T
2 2 6 TA
Output
8
2
4
Explanation
Pattern ATGC aligned at position matches all eight DNA characters. Pattern TTT aligned at position matches two positions within . After changing position to T, pattern TA aligned at position matches four positions.