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

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

Is It a p-drome?

시간 제한5초메모리 제한256 MB

요약
순열 p와 문자열 s가 주어질 때, 모든 위치에서 t[i] = t[p[i]]를 만족하는 s의 길이 n 부분 문자열을 표시한다.
난이도

보통10점 중 6점

유형
문자열 매칭, 해시맵, 문자열
정답자
아직 제출이 없습니다

문제

Let's suppose that we have fixed a permutation pp with length nn. We say that a string tt is a pp-drome if it has the length nn, and for all the characters of this string, it is true that t_i=t_p_it\_i = t\_{p\_i}.

You have a string ss and a permutation pp. For each substring of ss of length nn, you have to find out if it is a pp-drome or not.

입력

On the first line, you are given three integers nn, mm, and cc: the length of the permutation, the length of the string and the size of the alphabet of the string (1≤n≤m≤500,0001 \le n \le m \le 500\\,000; 1≤c≤500,0001 \le c \le 500\\,000).

On the second line, you are given nn integers p_ip\_i: the permutation itsekf (1≤p_i≤n1 \le p\_i \le n; p_i≠p_jp\_i \ne p\_j if i≠ji \ne j).

On the third line, you are given mm integers s_is\_i: the initial string (1≤s_i≤c1 \le s\_i \le c).

출력

Print m−n+1m-n+1 characters without spaces: ii-th character must be "1" if substring s_i…s_i+n−1s\_i \ldots s\_{i+n-1} is a pp-drome, and "0" otherwise.

예제2

  1. 예제 1

    입력
    3 5 1
    1 2 3
    1 1 1 1 1
    
    예상 출력
    111
    
  2. 예제 2

    입력
    3 7 3
    3 2 1
    1 2 1 3 1 2 1
    
    예상 출력
    10101