#P9806. Identify Potentially Recorded Vehicles

    ID: 22952 Type: Default 1000ms 256MiB

Identify Potentially Recorded Vehicles

Identify Potentially Recorded Vehicles

Two friends, A and B, are recording vehicle types from a long list. There are \(k\) types of vehicles (numbered from \(1\) to \(k\)). Friend A carefully records the type of every vehicle in order, resulting in a sequence of length \(n\). Friend B, being less attentive, only records a subsequence of these vehicles (of length \(m\)), and it is guaranteed that B's sequence is a subsequence of A's sequence.

We say that the \(i\)th vehicle in A's record "might have been recorded by B" if there exists an occurrence of B's entire sequence as a subsequence of A's record that includes the \(i\)th vehicle. In other words, if we can choose indices \(i_1, i_2, \dots, i_m\) in A (with \(1 \le i_1 < i_2 < \cdots < i_m \le n\)) such that \(A[i_j] = B[j]\) for all \(1 \le j \le m\) and for some index \(j\) we have \(i = i_j\), then the \(i\)th vehicle is considered as potentially recorded by B.

Your task is to determine, for each vehicle in A's record, whether it can possibly be one of the vehicles recorded by B. Output "YES" for a vehicle that might have been recorded and "NO" otherwise.

inputFormat

The first line contains three integers \(n\), \(m\), and \(k\) \((1 \le m \le n,\ k \ge 1)\) -- the lengths of A's record, B's record, as well as the number of vehicle types.

The second line contains \(n\) integers \(A_1, A_2, \dots, A_n\) where \(1 \le A_i \le k\), representing the vehicle types in A's record.

The third line contains \(m\) integers \(B_1, B_2, \dots, B_m\) where \(1 \le B_j \le k\), representing the vehicle types in B's record. It is guaranteed that \(B\) is a subsequence of \(A\).

outputFormat

Output a single line containing \(n\) tokens separated by spaces. The \(i\)th token should be "YES" if the \(i\)th vehicle in A's record might have been recorded by B, and "NO" otherwise.

sample

5 3 3
1 2 3 1 2
1 1 2
YES NO NO YES YES