아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

KK Integers

시간 제한2초메모리 제한512 MB

요약
문자열과 인덱스 수열 t가 주어질 때, t에 대응하는 문자들을 부분수열로 포함하면서 사전순으로 가장 작은 문자열의 부분수열을 구한다.
난이도

보통10점 중 6점

유형
그리디, 문자열, 구현
정답자
아직 제출이 없습니다

문제

You are given a string ss of length nn.

A sequence of integers tt is an index sequence if 1≤t_1<t_2<…<t_k≤n1 \leq t\_1 < t\_2 < \ldots < t\_k \leq n, where kk is the length of tt.

A string corresponding to an index sequence tt is the the following string: s_t_1s_t_2…s_t_ks\_{t\_1} s\_{t\_2} \ldots s\_{t\_k}. Note that it is always a subsequence of ss.

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 ss consisting of nn (1≤n≤5⋅1051 \leq n \leq 5 \cdot 10^5) lowercase English letters.

The second line contains a single integer kk (1≤k≤n1 \leq k \leq n), length of tt.

The third line contains kk integers t_it\_i (1≤t_i≤n1 \leq t\_i \leq n). tt is an index sequence.

출력

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

예제8

  1. 예제 1

    입력
    links
    2
    3 4
    
    예상 출력
    ink
    
  2. 예제 2

    입력
    abacaba
    2
    4 6
    
    예상 출력
    aacab
    
  3. 예제 3

    입력
    pepega
    2
    2 6
    
    예상 출력
    ea
    
  4. 예제 4

    입력
    gaypride
    2
    6 7
    
    예상 출력
    aid
    
  5. 예제 5

    입력
    pogchamp
    3
    1 2 3
    
    예상 출력
    pog
    
  6. 예제 6

    입력
    frankerz
    1
    8
    
    예상 출력
    aerz
    
  7. 예제 7

    입력
    blessrng
    8
    1 2 3 4 5 6 7 8
    
    예상 출력
    blessrng
    
  8. 예제 8

    입력
    residentsleeper
    4
    1 3 7 15
    
    예상 출력
    resdeneeer