出来冒个泡

由于数比较大  开了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. Sqli-labs less 52

    Less-52 和less50是一样的,只是这里的mysql错误不会在前台显示,但是对于stacked injection是一样的利用方式 http://127.0.0.1/sqli-labs/Les ...

  2. codeforces 439D Devu and Partitioning of the Array(有深度的模拟)

    题目 //参考了网上的代码 注意答案可能超过32位 //要达成目标,就是要所有数列a的都比数列b的要小或者等于 //然后,要使最小的要和最大的一样大,就要移动(大-小)步, //要使较小的要和较大的一 ...

  3. poj 3684

    Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 784   Accepted: 266 ...

  4. poj 3114(强连通缩点+SPFA)

    题目链接:http://poj.org/problem?id=3114 思路:题目要求很简单,就是求两点之间的花费的最短时间,不过有一个要求:如果这两个city属于同一个国家,则花费时间为0.如何判断 ...

  5. Java-马士兵设计模式学习笔记-观察者模式-OOD 封装event

    把小孩醒来时的具体情况封装成事件类 Test.java class WakenUpEvent{ private long time; private String location; private ...

  6. QT中显示GIF图片

    在QT中要显示GIF图片,不能通过单单的添加部件来完成. 还需要手动的编写程序. 工具:QT Creator 新建一个工程,我们先在designer中,添加一个QLabel部件. 如下图: 将QLab ...

  7. IntelliJ IDEA:Getting Started with Spring MVC, Hibernate and JSON实践

    原文:IntelliJ IDEA:Getting Started with Spring MVC, Hibernate and JSON实践 最近把编辑器换成IntelliJ IDEA,主要是Ecli ...

  8. Gray code---hdu5375(格雷码与二进制码,普通dp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5375 题意就是:给你一串二进制码,里面可能含有'?'这个既可以表示0又可以表示1, 让我们把这个二进制 ...

  9. Java实现Mysql数据导入导出

    package com.backup; import java.io.BufferedReader;import java.io.FileInputStream;import java.io.File ...

  10. BI

    http://www.cnblogs.com/biwork/p/3276455.html http://www.cnblogs.com/biwork/p/3328879.html http://www ...