传送门

题目:

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. 每日一皮:为什么程序猿是最适合谈恋爱的人
  2. 【转载】如何使用STM32的窗口看门狗
  3. python 文件操作 os.mkdir()函数
  4. python自动化框架2019_【转】python3实现自动化框架robotframework
  5. iOS通用链接(Universal Links)突然点击无效的解决方案
  6. php dio获取串口数据,flutter通过dio读取二进制数据,比如通过api接口读取图片
  7. Android 中进程的级别以及 Service 的优先级
  8. php mysql访问不,php不能访问mysql怎么办
  9. 分享一个USB转杜邦线 5V取电的3D打印件,附3D打印文件
  10. python罗马数字转换,Python 罗马数字转换整数
  11. 2022-2028全球智能门锁系统行业调研及趋势分析报告
  12. 词根词缀|ori/orn/ortho/pact/pan及词源O的故事
  13. 运动品牌推荐:2022年最值得入手的一些运动装备
  14. 电脑键盘部分按键失灵_键盘失灵个别字母不灵怎么处理_电脑键盘个别键没反应如何修复...
  15. 【新年返程离不开Python】最新12306抢票源程序Python版就此分享给大家啦!
  16. 利用Matlab编写龙贝格算法(romberg)求函数积分
  17. 计算机网络实验路由器,计算机网络路由器配置实验.doc
  18. 小米扫地机器人 设置虚拟墙_米家扫地机器人可以设置虚拟墙吗
  19. 中国iaas产业2012年度点评
  20. 统信UOS安装 执行 curl命令

热门文章

  1. 计算机唤醒休眠蓝屏,分享win10睡眠唤醒就蓝屏的解决办法
  2. 如何让程序运行后不谈程序兼容性助手
  3. 水利水电安全员考试单选练习题库(11)
  4. Python3 使用科大讯飞 API 接口实现音频文件转写
  5. 数据结构概述3 对称矩阵、树和二叉树
  6. flutter 如何实现上下标效果
  7. android+属性动画+高度,android 自定义view+属性动画实现充电进度条
  8. 01 【介绍 使用步骤 引入方式 基础配置】
  9. 邮件发送求职简历四大注意事项
  10. BZOJ 4668: 冷战 并查集暴力LCA(雾)