#CT00040. Truy vấn giải nén (Decompression Queries)
Truy vấn giải nén (Decompression Queries)
Decompression Queries
Version: Phuoc Hung OJ Extended
Problem Statement
An original string was run-length encoded: every maximal consecutive run of equal uppercase letters is represented by its letter followed by a positive integer count. The encoded string is therefore a sequence of letter-count pairs, and a count may contain multiple digits.
The original string may be too long to materialize in memory.
There are queries. Query gives a 1-based position in the original string. Determine the character at that position for every query, then concatenate the answers in query order into a string of length .
Input
- Line 1 contains a valid encoded string .
- Line 2 contains the positive integer .
- Line 3 contains positive integers . Every is at most the decompressed length.
Output
Print a string of exactly characters. Its -th character is the character at position in the original string.
Subtasks
- Subtask 1 (30 points): the decompressed length is at most and .
- Subtask 2 (30 points): .
- Subtask 3 (40 points): no additional restriction.
- In every subtask: , , and the decompressed length is at most .
Examples
Input
A3B1C4D3A1
5
1 4 8 9 12
Output
ABCDA
Explanation
The encoded string represents AAABCCCCDDDA. Positions lie in the runs for A, B, C, D, and A respectively, so the answer is ABCDA.
Liên quan
Trong các cuộc thi sau:
Phước Hưng - Kỳ Thi HSG Lớp 9 (Chuyên đề Xử Lý Chuỗi) - Đề Số 3