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

23683번 - $K$ Integers 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 512 MB122231619.512%

문제

You are given a string $s$ of length $n$.

A sequence of integers $t$ is an index sequence if 1ドル \leq t_1 < t_2 < \ldots < t_k \leq n,ドル where $k$ is the length of $t$.

A string corresponding to an index sequence $t$ is the the following string: $s_{t_1} s_{t_2} \ldots s_{t_k}$. Note that it is always a subsequence of $s$.

You are given an index sequence. Find the lexicographically smallest string which corresponds to some index sequence which contains the given one as a subsequence.

입력

The first line contains the string $s$ consisting of $n$ (1ドル \leq n \leq 5 \cdot 10^5$) lowercase English letters.

The second line contains a single integer $k$ (1ドル \leq k \leq n$), length of $t$.

The third line contains $k$ integers $t_i$ (1ドル \leq t_i \leq n$). $t$ is an index sequence.

출력

Print a single string --- the answer to the problem.

제한

예제 입력 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

힌트

출처

Contest > Open Cup > 2018/2019 Season > Stage 13: Grand Prix of Bytedance K번

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

출처

대학교 대회

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

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