http://codeforces.com/contest/368/problem/D

 #include <cstdio>
#include <cstring>
#include <map>
#include <vector>
#include <algorithm>
#define maxn 300000
#define LL long long
using namespace std; int n,m,p;
LL a[maxn],b[maxn];
vector<int>g; int main()
{
while(scanf("%d%d%d",&n,&m,&p)!=EOF)
{
for(int i=; i<n; i++)
{
scanf("%lld",&a[i]);
}
for(int i=; i<m; i++)
{
scanf("%lld",&b[i]);
}
for(int i=; i<p&&i+(LL)(m-)*p<n; i++)
{
map<int,int>q;
for(int j=; j<m; j++)
{
q[b[j]]++;
}
int c=i;
for(int j=; j<m; j++)
{
q[a[c]]--;
if(q[a[c]]==)
{
q.erase(a[c]);
}
c+=p;
}
for(int j=i; ; j+=p,c+=p)
{
if(!q.size()) g.push_back(j+);
if(c>=n) break;
if(--q[a[c]]==) q.erase(a[c]);
if(++q[a[j]]==) q.erase(a[j]);
}
}
sort(g.begin(),g.end());
printf("%d\n",g.size());
for(int i=; i<(int)g.size(); i++)
{
printf("%d ",g[i]);
}
printf("\n");
}
return ;
}

cf D. Sereja ans Anagrams的更多相关文章

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

  2. Sereja ans Anagrams 优先队列控制

    Sereja has two sequences a and b and number p. Sequence a consists of n integers a1, a2, ..., an. Si ...

  3. Sereja ans Anagrams

    Codeforces Round #215 (Div. 1) B:http://codeforces.com/problemset/problem/367/B 题意:给你两个序列a,b,然后给你一个数 ...

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

  5. CF 314C Sereja and Subsequences(树状数组)

    题目链接:http://codeforces.com/problemset/problem/314/C 题意:给定一个数列a.(1)写出a的不同的所有非下降子列:(2)定义某个子列的f值为数列中各个数 ...

  6. 【CF】Sereja and Arcs

    #include <bits/stdc++.h> #define llong long long using namespace std; const int N = 1e5; const ...

  7. cf C. Sereja and Algorithm

    http://codeforces.com/contest/368/problem/C 从左向右记录从1位置到每一个位置上x,y,z的个数.然后判断在l,r区间内的x,y,z的关系满不满足abs(x- ...

  8. cf B. Sereja and Suffixes

    http://codeforces.com/contest/368/problem/B 从后往前找一遍就可以. #include <cstdio> #include <cstring ...

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

随机推荐

  1. 【转】Linux 中断学习之小试牛刀篇

    原文网址:http://www.linuxidc.com/Linux/2011-02/32129.htm 前言 在前面分析了中断的基本原理后,就可以写一个内核中断程序来体验以下,也可以借此程序继续深入 ...

  2. 【转】Android中Spinner下拉列表(使用ArrayAdapter和自定义Adapter实现)

    原文网址:http://embed.21ic.com/software/android/201403/31603.html 1 :Android中Spinner下拉列表(使用ArrayAdapter和 ...

  3. JFreeChart学习

    一.步骤: 创建数据集(准备数据) 根据数据集生成JFreeChart对象,并对其做相应的设置(标题,图例,x轴,Y轴,对象渲染等) 将JFreeChart对象输出到文件或者Servlet输出流等 二 ...

  4. CSS 代码是什么?(转)

    转自:http://www.divcss5.com/rumen/r95.shtml CSS 代码是什么,什么是CSS代码? 目录 什么是CSS css代码样子(图) 作用 相关扩展阅读 一.了解什么是 ...

  5. yii 使用 phpmailer发送邮件

    原文链接 :  http://www.yiiframework.com/extension/mailer/ 下载插件放在 :XXX/protected/extensions/ 作为一个普通的组建使用 ...

  6. Javascript:DOM动态创建元素实例应用

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

  7. Javascript 精髓整理篇之三(数组篇)postby:http://zhutty.cnblogs.com

    今天讲js的数组.数组是js中最基础的数据结构了. 主要讲讲数组实现栈,队列以及其他的基本操作.栈和队列都可以在数组头尾位置处理,所以,都有两种方式. 属性 1.length : 长度,表示数组元素的 ...

  8. i++与++i的区别,使用实例说明

    /** * 类名:TEST.java<br> * <p> * 功能:i++与++i的区别,使用实例说明 * </p> * * @Author:<a href= ...

  9. IOS开发之微博的设计与实现

    // // main.m // Microblog // #import <Foundation/Foundation.h> #import "Person.h" #i ...

  10. c++ 连接两个字符串实现代码 实现类似strcat功能(转)

    想实现strcat功能,直接网上找一个. 第一种: #include "stdafx.h" #include<iostream> using namespace std ...