Codeforces Round 543 (Div. 2, based on Technocup 2019 Final Round)
D
Diana and Liana
Codeforces
未评级
原题
← CE →
翻译中…

At the first holiday in spring, the town Shortriver traditionally conducts a flower festival. Townsfolk wear traditional wreaths during these festivals. Each wreath contains exactly k flowers.

翻译中…

The work material for the wreaths for all n citizens of Shortriver is cut from the longest flowered liana that grew in the town that year. Liana is a sequence a1, a2, ..., am, where ai is an integer that denotes the type of flower at the position i. This year the liana is very long (m≥n⋅k), and that means every citizen will get a wreath.

翻译中…

Very soon the liana will be inserted into a special cutting machine in order to make work material for wreaths. The machine works in a simple manner: it cuts k flowers from the beginning of the liana, then another k flowers and so on. Each such piece of k flowers is called a workpiece. The machine works until there are less than k flowers on the liana.

翻译中…

Diana has found a weaving schematic for the most beautiful wreath imaginable. In order to weave it, k flowers must contain flowers of types b1, b2, ..., bs, while other can be of any type. If a type appears in this sequence several times, there should be at least that many flowers of that type as the number of occurrences of this flower in the sequence. The order of the flowers in a workpiece does not matter.

翻译中…

Diana has a chance to remove some flowers from the liana before it is inserted into the cutting machine. She can remove flowers from any part of the liana without breaking liana into pieces. If Diana removes too many flowers, it may happen so that some of the citizens do not get a wreath. Could some flowers be removed from the liana so that at least one workpiece would conform to the schematic and machine would still be able to create at least n workpieces?

翻译中…

Input

翻译中…

The first line contains four integers m, k, n and s (1≤n,k,m≤5⋅105, k⋅n≤m, 1≤s≤k): the number of flowers on the liana, the number of flowers in one wreath, the amount of citizens and the length of Diana's flower sequence respectively.

翻译中…

The second line contains m integers a1, a2, ..., am (1≤ai≤5⋅105)  — types of flowers on the liana.

翻译中…

The third line contains s integers b1, b2, ..., bs (1≤bi≤5⋅105)  — the sequence in Diana's schematic.

翻译中…

Output

翻译中…

If it's impossible to remove some of the flowers so that there would be at least n workpieces and at least one of them fullfills Diana's schematic requirements, output −1.

翻译中…

Otherwise in the first line output one integer d  — the number of flowers to be removed by Diana.

翻译中…

In the next line output d different integers  — the positions of the flowers to be removed.

翻译中…

If there are multiple answers, print any.

翻译中…

Note

翻译中…

In the first example, if you don't remove any flowers, the machine would put out two workpieces with flower types [1,2,3] and [3,2,1]. Those workpieces don't fit Diana's schematic. But if you remove flower on 4-th place, the machine would output workpieces [1,2,3] and [2,1,2]. The second workpiece fits Diana's schematic.

翻译中…

In the second example there is no way to remove flowers so that every citizen gets a wreath and Diana gets a workpiece that fits here schematic.

翻译中…

In the third example Diana is the only citizen of the town and that means she can, for example, just remove all flowers except the ones she needs.

翻译中…

样例

Input #1
7 3 2 2
1 2 3 3 2 1 2
2 2
Output #1
1
4
InputCopy OutputCopy
Input #2
13 4 3 3
3 2 6 4 1 4 4 7 1 3 3 2 4
4 3 4
Output #2
-1
InputCopy OutputCopy
Input #3
13 4 1 3
3 2 6 4 1 4 4 7 1 3 3 2 4
4 3 4
Output #3
9
1 2 3 4 5 9 11 12 13
InputCopy OutputCopy
题目信息
题号
1121D
时间限制
2 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。