#P9806. [POI 2022/2023 R1] poc

[POI 2022/2023 R1] poc

Background

This problem is translated from POI2022~2023R1 poc.

Problem Description

Little A and Little B are recording the types of vehicles that passed by.

There are 1k1 \sim k types in total, and every vehicle must belong to exactly one of them.

Little A carefully recorded the types of all vehicles in order, while playful Little B only recorded some of the vehicles in order.

The length of Little A’s record is nn, and the length of Little B’s record is mm.

We say that the ii-th vehicle in Little A’s record “may have been recorded by B” if and only if there exists a subsequence of Little A’s record that contains position ii and is exactly the same as the sequence recorded by Little B.

It is guaranteed that Little B’s sequence is a subsequence of Little A’s sequence. Determine which vehicles may have been recorded by Little B and which may not.

Input Format

The first line contains three integers n,m,k (1n,m,k3×105)n, m, k \ (1 \leq n, m, k \leq 3 \times 10^5).

The second line contains a sequence of length nn, representing the sequence recorded by Little A.

The third line contains a sequence of length mm, representing the sequence recorded by Little B.

All elements in the sequences satisfy 11 \leq sequence element k\leq k.

Output Format

For each vehicle recorded by Little A, determine whether it can be recorded by Little B. Output 11 if it can, and 00 otherwise.

9 4 3
1 3 2 1 2 3 1 3 2
1 3 1 2

1 1 0 1 1 1 1 0 1

Hint

For the sample, the following subsequences exist:

(1,2,4,5)(1,2,4,5), (1,2,4,9)(1,2,4,9), (1,2,7,9)(1,2,7,9), (1,6,7,9)(1,6,7,9), (4,6,7,9)(4,6,7,9).

Note that 33 and 88 are never chosen, so they cannot be recorded by Little B.

The subtasks are as follows:

Subtask ID Special Property Score
11 n,m100n, m \leq 100 1515
22 n,m2000n, m \leq 2000 2020
33 Each vehicle type is recorded by Little A at most once 1515
44 No additional constraints 5050

Time limit: Subtask 1 1s, Subtask 2 10s, Subtask 3 and Subtask 4 6s.

Translated by ChatGPT 5