出来冒个泡

由于数比较大  开了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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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+ ...

  4. Codeforces Round #215 (Div. 2) C. Sereja and Algorithm

    #include <iostream> #include <vector> #include <algorithm> #include <string> ...

  5. Codeforces Round #215 (Div. 2) B. Sereja and Suffixes

    #include <iostream> #include <vector> #include <algorithm> #include <set> us ...

  6. Codeforces Round #215 (Div. 2) A. Sereja and Coat Rack

    #include <iostream> #include <vector> #include <algorithm> using namespace std; in ...

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

  8. Codeforces Round #215 (Div. 1)

    A Sereja and Algorithm 题意:给定有x,y,z组成的字符串,每次询问某一段s[l, r]能否变成变成zyxzyx的循环体. 分析: 分析每一段x,y,z数目是否满足构成循环体,当 ...

  9. 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 ...

随机推荐

  1. CSS3 3D变换

    可以这么说,3D变换是基于三维坐标系的.以下是“盗用”的图 CSS3中的3D变换主要包括以下几个功能函数: 3D位移:包括translateZ()和translate3d(): 3D旋转:包括rota ...

  2. 在当前iframe中, 获取Iframe的id

    window.frameElement   返回嵌入当前window对象的元素(比如 <iframe> 或者 <object>),如果当前window对象已经是顶层窗口,则返回 ...

  3. DSP中常用的C语言关键字

    const Ø使用:const 数据类型 变量名: Ø作用:优化存储器的分配,表示变量的内容是常数,不会改变. Ø举例:const char tab[1024]={显示数据}; volatile(易变 ...

  4. 几个Google中国的访问IP

    前面几个IP的访问速度比较快. 74.125.31.106 173.194.45.20 173.194.45.19 173.194.45.18 173.194.45.17 173.194.45.16 ...

  5. C#与C++之间类型的对应{转}

    Windows Data Type   .NET Data Type BOOL, BOOLEAN   Boolean or Int32 BSTR    String BYTE    Byte CHAR ...

  6. javascript设计模式--备忘录模式(Memento)

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. (转载)李剑英的CSLight入门指南结合NGUI热更新

    原地址:http://www.xuanyusong.com/archives/3075 李剑英的CSLight入门指南文档撰写者:GraphicQQ: 1065147807 一. CSLIGHT 作者 ...

  8. POJ 2992 Divisors (求因子个数)

    题意:给n和k,求组合C(n,k)的因子个数. 这道题,若一开始先预处理出C[i][j]的大小,再按普通方法枚举2~sqrt(C[i][j])来求解对应的因子个数,会TLE.所以得用别的方法. 在说方 ...

  9. POJ 1006 Biorhythms (中国剩余定理)

    在POJ上有译文(原文右上角),选择语言:简体中文 求解同余方程组:x=ai(mod mi) i=1~r, m1,m2,...,mr互质利用中国剩余定理令M=m1*m2*...*mr,Mi=M/mi因 ...

  10. Ehcache使用

    http://www.360doc.com/content/14/0423/17/16946725_371472946.shtml http://www.myexception.cn/web-appl ...