Codeforces Round #215 (Div. 1) B
出来冒个泡
由于数比较大 开了map计数 然后边走边删边加 勉强可过
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<queue>
#include<map>
#include<string>
using namespace std;
#define LL long long
#define N 200010
int a[N],b[N],ff[N],o[N],g,vis[N];
map<int,int>f;
map<int,int>q;
map<int,int>qq;
int main()
{
int i,kq=;
LL n,m,p;
cin>>n>>m>>p;
for(i = ; i <= n ; i++)
cin>>a[i];
for(i = ; i <= m ; i++)
{
cin>>b[i];
if(!q[b[i]]) kq++;
q[b[i]]++;
}
int k = ;
for(int e = ; e <= n ; e++)
{
if(vis[e]) continue;
if(e+(m-)*p>n) break;
k = ;
f.clear();qq.clear();
while(k<m&&e+k*p<=n)
{
f[a[e+k*p]]++;
vis[e+k*p] = ;
k++;
}
int s=;
for(i = ; i <= m ; i++)
{
if(f[b[i]]==q[b[i]]&&!qq[b[i]])
{
s++;
qq[b[i]] = ;
}
}
if(s==kq)
{
g++;
o[g] = e;
}
int j = e+p;
while(j+(m-)*p<=n)
{
int k1 = f[a[j-p]],k2 = q[a[j-p]],k3 = f[a[j+(m-)*p]],k4 = q[a[j+(m-)*p]];
f[a[j-p]]--;
f[a[j+(m-)*p]]++;
vis[j+(m-)*p] = ;
if(a[j-p]!=a[j+(m-)*p])
{
if(q[a[j-p]])
{
if(k1==k2)
s--;
else if(f[a[j-p]]==q[a[j-p]]){s++;}
}
if(q[a[j+(m-)*p]])
{
if(k3==k4) s--;
else if(f[a[j+(m-)*p]]==q[a[j+(m-)*p]]) s++;
}
}
if(s==kq)
{
g++;
o[g] = j;
}
j+=p;
}
}
sort(o+,o+g+);
cout<<g<<endl;
for(i = ; i <= g ; i++)
cout<<o[i]<<" ";
return ;
}
Codeforces Round #215 (Div. 1) B的更多相关文章
- Codeforces Round #215 (Div. 2) B. Sereja and Suffixes map
B. Sereja and Suffixes Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset ...
- Codeforces Round #215 (Div. 1) B. Sereja ans Anagrams 匹配
B. Sereja ans Anagrams Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset ...
- Codeforces Round #215 (Div. 2) D. Sereja ans Anagrams
http://codeforces.com/contest/368/problem/D 题意:有a.b两个数组,a数组有n个数,b数组有m个数,现在给出一个p,要你找出所有的位置q,使得位置q q+ ...
- Codeforces Round #215 (Div. 2) C. Sereja and Algorithm
#include <iostream> #include <vector> #include <algorithm> #include <string> ...
- Codeforces Round #215 (Div. 2) B. Sereja and Suffixes
#include <iostream> #include <vector> #include <algorithm> #include <set> us ...
- Codeforces Round #215 (Div. 2) A. Sereja and Coat Rack
#include <iostream> #include <vector> #include <algorithm> using namespace std; in ...
- Codeforces Round #215 (Div. 2) D题(离散化+hash)
D. Sereja ans Anagrams time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Codeforces Round #215 (Div. 1)
A Sereja and Algorithm 题意:给定有x,y,z组成的字符串,每次询问某一段s[l, r]能否变成变成zyxzyx的循环体. 分析: 分析每一段x,y,z数目是否满足构成循环体,当 ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
随机推荐
- 0910 noip模拟
教师节快乐: T1:勇士闯魔塔,是一道很裸的莫队题目,但在老师的催促下,出题人@syq同学修改了第一题,使之成了一道送分题,全暴力水过: T2:第二题是一道预处理+分组背包,考试中,忘了分组背包怎么敲 ...
- Oracle 导入导出数据 imp/exp impdp/expdp
IMPDP/EXPDP 一.创建逻辑目录,该命令不会在操作系统创建真正的目录,最好以system等管理员创建. create directory dpdata as '/opt'; 二 ...
- 一系列JavaScript的基础工具
在我们的bootcamp训练营中,学员们介绍了一些工具和库来扩展他们代码的能力.Kalina,目前我们JavaScript学员中的一员,列举了这些工具,想和其它爱好代码的小伙伴一起分享. 点击看大图 ...
- geotools解析SLD中的elsefilter为什么里面的filter无效
原因是在org.geotools.renderer.lite.StreamingRenderer中的process函数: /** * @param rf * @param feature * @par ...
- 一张思维导图说明jQuery的AJAX请求机制
比文字描述清晰多了吧?而且越是复杂的逻辑,思维导图的作用就越大,同时对阅读源码也是一种快捷的方法. 看不清楚的话可以右键,在新标签页中打开图片,或者保存本地.
- AssetBundle机制相关资料收集
原地址:http://www.cnblogs.com/realtimepixels/p/3652075.html AssetBundle机制相关资料收集 最近网友通过网站搜索Unity3D在手机及其他 ...
- rm删除命令
linux中删除文件和目录的命令: rm命令.rm是常用的命令,该命令的功能为删除一个目录中的一个或多个文件或目录,它也可以将某个目录及其下的所有文件及子目录均删除.对于链接文件,只是删除了链接,原有 ...
- ASP.NET MVC的处理管线
原文:http://www.cnblogs.com/fzrain/p/3651693.html 下面开始解释各个部分: 路由模块 1.在ASP.NET MVC处理管线中的第一站就是路由模块.当请求到达 ...
- DevOps:怎么实现源代码注释和系统文档的自动化更新?
[编者按]计算机软件传统定义为:软件是计算机系统中与硬件相依存的另一部分,软件包括程序.数据及其相关文档的完整集合.然而在时下的开发中,文档的合规性往往被忽视的干干净净.本文由 Todd Waits ...
- 超快的 FastText
Word2Vec 作者.脸书科学家 Mikolov 文本分类新作 fastText:方法简单,号称并不需要深度学习那样几小时或者几天的训练时间,在普通 CPU 上最快几十秒就可以训练模型,得到不错的结 ...