QOJ.ac

QOJ

Limite de temps : 2.0 s Limite de mémoire : 512 MB Points totaux : 100

#18046. $K$ 个整数

Statistiques

给你一个长度为 $n$ 的字符串 $s$。

一个整数序列 $t$ 被称为索引序列,如果满足 $1 \le t_1 < t_2 < \dots < t_k \le n$,其中 $k$ 是 $t$ 的长度。

与索引序列 $t$ 对应的字符串定义为:$s_{t_1} s_{t_2} \dots s_{t_k}$。请注意,该字符串总是 $s$ 的一个子序列。

现在给你一个索引序列。请找到一个字典序最小的字符串,它对应于某个包含给定索引序列作为子序列的索引序列。

输入格式

第一行包含一个由 $n$ ($1 \le n \le 5 \cdot 10^5$) 个小写英文字母组成的字符串 $s$。

第二行包含一个整数 $k$ ($1 \le k \le n$),表示 $t$ 的长度。

第三行包含 $k$ 个整数 $t_i$ ($1 \le t_i \le n$)。保证 $t$ 是一个索引序列。

输出格式

输出一个字符串——问题的答案。

样例

输入样例 1

links
2
3 4

输出样例 1

ink

输入样例 2

abacaba
2
4 6

输出样例 2

aacab

输入样例 3

pepega
2
2 6

输出样例 3

ea

输入样例 4

gaypride
2
6 7

输出样例 4

aid

输入样例 5

pogchamp
3
1 2 3

输出样例 5

pog

输入样例 6

frankerz
1
8

输出样例 6

aerz

输入样例 7

blessrng
8
1 2 3 4 5 6 7 8

输出样例 7

blessrng

输入样例 8

residentsleeper
4
1 3 7 15

输出样例 8

resdeneeer

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.