出来冒个泡

由于数比较大  开了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. 6-Highcharts曲线图之带标识

    <!DOCTYPE> <html lang='en'> <head> <title>6-Highcharts曲线图之带标识</title> ...

  2. js java正则表达式替换手机号4-7位为星*号

    需求: 一个手机号13152461111,由于安全性,需要替换4-7位字符串为星号,为131****1111,那么有2中玩法,一种是前端隐藏,一种是后台隐藏. 1. 前台隐藏 <!DOCTYPE ...

  3. wireshark常用的过滤命令

    我们使用wireshark抓包,却不知道如何分析这些包,也无法从海量的包中提取自己需要的数据,下面简单介绍下wireshark的过滤规则. 过滤源ip.目的ip.在wireshark的过滤规则框Fil ...

  4. 《EnterLib PIAB深入剖析》系列博文汇总_转

    转: http://www.cnblogs.com/artech/archive/2008/08/08/1263418.html

  5. 利用excel数据透视表实现快速统计相关数据

    昨天ytkah在做数据报表时需要做一些具体统计数字:公司每天都有人申请铅笔.笔记本等一些文具用品,现在想要统计每天申请铅笔多少支.笔记本多少本,如下图所示,这个要如何实现呢? excel数据透视表怎么 ...

  6. logback日志配置文件代码示例

    <?xml version="1.0" encoding="UTF-8"?> <configuration scan="true&q ...

  7. Delphi中@,^,#,$特殊符号意义

    概述:   ^: 指针   @: 取址   #: 十进制符   $: 十六进制符   @:取址运算符; var   int:integer;   p:^integer; begin   new(P); ...

  8. uva 11090

    I I U P C 2 0 0 6 Problem G: Going in Cycle!! Input: standard input Output: standard output You are ...

  9. 在linux服务器上装svn版本管理,自动部署代码到项目

    在linux服务器上装svn版本管理,自动部署代码到项目 http://bbs.aliyun.com/read/9715.html?spm=5176.7114037.1996646101.1.W3zw ...

  10. Apache POI 解析 microsoft word 图片文字都不放过

    http://blog.csdn.net/njchenyi/article/details/6894500 http://haohaoxuexi.iteye.com/blog/2031335