传送门

题目:

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 kk flowers.

The work material for the wreaths for all nn citizens of Shortriver is cut from the longest flowered liana that grew in the town that year. Liana is a sequence a1a1, a2a2, ..., amam, where aiai is an integer that denotes the type of flower at the position ii. This year the liana is very long (m≥n⋅km≥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 kk flowers from the beginning of the liana, then another kk flowers and so on. Each such piece of kk flowers is called a workpiece. The machine works until there are less than kk flowers on the liana.

Diana has found a weaving schematic for the most beautiful wreath imaginable. In order to weave it, kk flowers must contain flowers of types b1b1, b2b2, ..., bsbs, 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 nn workpieces?

Input

The first line contains four integers mm, kk, nn and ss (1≤n,k,m≤5⋅1051≤n,k,m≤5⋅105, k⋅n≤mk⋅n≤m, 1≤s≤k1≤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 mm integers a1a1, a2a2, ..., amam (1≤ai≤5⋅1051≤ai≤5⋅105)  — types of flowers on the liana.

The third line contains ss integers b1b1, b2b2, ..., bsbs (1≤bi≤5⋅1051≤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 nn workpieces and at least one of them fullfills Diana's schematic requirements, output −1−1.

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

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

If there are multiple answers, print any.

Examples

input

Copy

7 3 2 2
1 2 3 3 2 1 2
2 2

output

Copy

1
4

input

Copy

13 4 3 3
3 2 6 4 1 4 4 7 1 3 3 2 4
4 3 4

output

Copy

-1

input

Copy

13 4 1 3
3 2 6 4 1 4 4 7 1 3 3 2 4
4 3 4

output

Copy

9
1 2 3 4 5 9 11 12 13

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][1,2,3] and [3,2,1][3,2,1]. Those workpieces don't fit Diana's schematic. But if you remove flower on 44-th place, the machine would output workpieces [1,2,3][1,2,3] and [2,1,2][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.

题意:给你两个字符串,要求将第一个字符串删除任意多的字符后,每k个构成一个花环,要求至少有一个花环包含第二个字符串的数量,不要求顺序,只要求数量

思路:求出第二个字符串中没一个字符串的数量和字符的种类数,然后定义两个指针,从l到r统计每个数出现的次数,如果相应字符数个数比第二个字符串打,子符种类数--,如果种类数为0就判断能不能构成n个花环,能就调出输出,不能就移动左限,删除左限的影响再继续进行操作;

AC代码:

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include<stdlib.h>
#include<math.h>
#define ll long long
using namespace std;
const int maxn=5e5+5;
int x[maxn];
int num[maxn],judge[maxn];
int main( )
{int m,k,n,s,num1=0;bool judge1=true;memset(num,0,sizeof(num));scanf("%d %d %d %d",&m,&k,&n,&s);for(int a=1;a<=m;a++)scanf("%d",&x[a]);for(int b=1;b<=s;b++){int i;scanf("%d",&i);if(num[i]==0)num1++;num[i]++;judge[i]=num[i];}int r=1,l;for(l=1;l<=m;l++){if(num1==0&&(r-l+1)>=s){num[x[l-1]]++;if(num[x[l-1]]>0)num1++;}while(r<=m&&num1>0){if(num[x[r]]==1)num1--;num[x[r]]--;//printf("%d %d %d\n",r,num1,num[x[r]]);r++;}if(num1!=0)break;if((l-1)/k+1+(m-r+1)/k>=n){judge1=false;break;}}if(judge1){printf("-1\n");return 0;}//printf("%d %d\n",l,r);r--;int ans=max(r-l+1-k,0);printf("%d\n",ans);for(int a=l;a<=r;a++){if(ans==0)break;if(judge[x[a]]>0)judge[x[a]]--;else{if(ans!=1)printf("%d ",a);elseprintf("%d\n",a);ans--;}}
}

Diana and Liana相关推荐

  1. #11.11 个人排位赛round2_A.Diana and Liana(CodeForces 1121D)

    A.Diana and Liana 题目链接在此! 这题也是心理变态出的.头疼! A.Diana and Liana(CodeForces 1121D) At the first holiday in ...

  2. 敏捷爽畅模型及其演变——Diana Larsen专访

    在Agile Open Northwest Open Space会议上,Diana Larsen与我们讨论了一些有关敏捷爽畅模型的运用和演变的问题.在此之后,Diana对话InfoQ,讲述了过去13年 ...

  3. ORA-04028: cannot generate diana for object xxx

    在ORACLE数据库(10.2.0.5.0)上修改一个包的时候,编译有错误,具体错误信息为"ORA-04028: cannot generate diana for object xxx&q ...

  4. 微星主板黑苹果_游戏机也玩二次元!微星全新“钛舞Diana”点亮冬日激情

    原标题:游戏机也玩二次元!微星全新"钛舞Diana"点亮冬日激情 宙斯盾"钛舞"终于要来啦!总算可以揭秘传说中的人工智能旋钮"炫镜轮"喽.作 ...

  5. CodeForces - 1559D2 Mocha and Diana (Hard Version)(思维)

    题目链接:点击查看 题目大意:给出两棵森林,每次可以同时在两个森林中增加同一条边,问最多可以增加多少条边,使得两个森林仍然还是森林 题目分析:结论参考至:https://blog.csdn.net/R ...

  6. codeforces1559 D2. Mocha and Diana (Hard Version)(并查集+启发式合并+随机化)

    D2. Mocha and Diana (Hard Version) RunningBeef题解 首先将图1的点与1号点所在的连通块相连,图2类似. 然后就是在图1和图2中选择没有和1号点在同一个连通 ...

  7. 宇信易诚Liana银行系统软件界面设计

    宇信易诚Liana银行系统软件界面设计

  8. 聚类算法之DIANA

    1. 算法描述 DIANA(Divisive ANAlysis)算法属于分裂的层次聚类.与凝聚的层次聚类相反,它采用一种自顶向下的策略,它首先将所有对象置于一个簇中,然后逐渐细分为越来越小的簇,直到每 ...

  9. Mocha and Diana (Easy Version) 并查集维护两片森林

    题意 : 给两片n个节点的森林,每次分别在两片森林的u和v节点之间加一条边,要求仍然是两片森林,求最多能加多少条边. 1≤

最新文章

  1. Linux三剑客之grep详解
  2. 7、linux网络编程--广播
  3. 将oracle冷备份恢复到另外一个数据库实例中
  4. AAAI 2021 | 用于图拓扑演化的深度图谱进化网络
  5. python快速入门课堂笔记_Python 快速入门笔记(10):文件及目录操作
  6. 知乎上高赞的40个有趣回复,很精辟!
  7. 对于公司,也是我对软件行业,软件项目的五想法
  8. mysql update 多个字段_MySQL数据库基础
  9. 2020 BrandZ全球品牌价值排行榜100强发布 TikTok首次上榜
  10. Jquery学习总结(3)——Jquery获取当前城市的天气信
  11. Java foreach remove问题分析
  12. 【Java数据结构】顺序存储的二叉树
  13. php 实现 word 转为 图片
  14. 【Python】调用WPS V9 API,实现PPT转PDF
  15. VCL组件DevExpress VCL v21.2 - PDF Viewer、图像列表编辑器升级
  16. html网页中加入音乐播放器,html 网页添加音乐播放器
  17. vue 使用qrcode生成二维码功能
  18. 2018 PHP面试真题(包括详细解析)
  19. 【C++课程设计】期末大作业 - 基于Qt开发的中国象棋软件
  20. 支付产品理解第二篇——闪付与手机支付

热门文章

  1. 2021年全球及中国三元前驱体行业现状及竞争格局分析,基于海外新能源汽车发展,我国是最大出口国「图」
  2. Shell脚本中dirname命令的使用
  3. 正常卸载Microsoft Office后无法重新安装?
  4. Docker安装好后默认路径
  5. MySQL监控系统Lepus
  6. python因子分析案例_python数据分析单因子分析
  7. Android微信App 分享功能调整,Android 微信SDK分享功能(1)
  8. 佳明比华为的手表好在哪
  9. 推荐几个免费的在线文本转语音网站(支持中英文多种语音)
  10. 复古儿童卡通温馨手绘风格趣味MOGRT图形动画标题pr模板