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 ...
随机推荐
- 玩具装箱 bzoj1010 斜率优化
斜率优化的题好像都是这样的方程:左边关于j,k的一个(...)/(...)的式子,右边是个只与i有关的可算的数字: 然后把它放到二维坐标轴上,用单调队列维护一个凸壳,O(n)的复杂度: 这道题但是我发 ...
- ios 聊天demo 和nsoperationdemo
http://blog.csdn.net/zhibudefeng/article/details/7991649 http://blog.csdn.net/kangx6/article/details ...
- 数据库表 copy
db1为原数据库,db2为要导出到的数据库,fromtable 是要导出的表名 1.方法一:登录导出到的数据库,执行create table fromtable select * from db1.f ...
- F.I.S本地环境的搭建教程
一.准备开发环境: 1.安装JRE 2.安装nodejs 最好是msi文件,比较省事. 3.(如果是PHP项目)安装php. 首先下载php(我的是5.5.15版本,win7 64位系统) zip,然 ...
- 再深入一点ajax
1.建立兼容性强的XHR对象有那么复杂么? 看过一些书,书上为了写针对低版本IE和其他非IE浏览器需要写一大串兼容函数,典型的就是JS高级程序上的. 可是在现实开发中,为了兼容IE6/IE7,只需要这 ...
- 传说中的WCF(4):发送和接收SOAP头
如果你实在不明白Header是个啥玩意儿,你就想一想你发送电子邮件时,是不是有个叫“附件”的东东?对啊,那么SOAP头是不是可以理解为一种附加信息?就是附加到消息正文的内容. 消息正文又是啥?WCF除 ...
- 【XJOI-NOIP16提高模拟训练9】题解。
http://www.hzxjhs.com:83/contest/55 说实话这次比赛真的很水..然而我只拿了140分,面壁反思. 第一题: 发现数位和sum最大就是9*18,k最大1000,那么su ...
- SQL server 为多个表添加新的列
作为一名.NET未入门的程序员,第一次发随笔. 前不久参与写的公司业务程序,目前这个程序的后期维护修复漏洞工作由我来负责.由于业务关系重大,每一步对程序代码的操作都非常谨慎,一旦操作失误,造成的损失和 ...
- 开始使用Mac OS X——写给Mac新人
本文转自博客园:http://www.cnblogs.com/chijianqiang/archive/2011/08/03/2126593.html 写这篇文档的原因有两个,一.身边使用Mac的朋友 ...
- 扩展 delphi 泛型 以实现类似lambda功能 , C#中的any count first last 等扩展方法
扩展 delphi 泛型 以实现类似lambda功能 , C#中的any count first last 等扩展方法 在C#中对泛型的扩展,输入参数是泛型本身的内容,返回值则是bool.基于这一点, ...