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. 【HDOJ】4972 A simple dynamic programming problem

    水题. #include <cstdio> #include <cstring> #include <cstdlib> int abs(int x) { ? -x: ...

  2. HDU-3661(贪心)

    Problem Description In a factory, there are N workers to finish two types of tasks (A and B). Each t ...

  3. JVM内存堆布局图解分析

    JAVA能够实现跨平台的一个根本原因,是定义了class文件的格式标准,凡是实现该标准的JVM都能够加载并解释该class文件,据此也可以知道,为啥Java语言的执行速度比C/C++语言执行的速度要慢 ...

  4. iOS--九宫格布局

    [self rankWithTotalColumns: andWithAppW: andWithAppH:]; //九宫格布局 - (void)rankWithTotalColumns:(int)to ...

  5. SQL Server 2008 导出数据与导入数据任务介绍

    一. 实例数据库介绍 源数据库Test_Other_DB:存在tb_Class,tb_Student,tb_TestTable三张表. 目标数据库TestDB_Output:空库,不含任何表. 二. ...

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

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

  7. 10个热门IT证书

    MCP (微软专家认证) CCNA (思科认证网络支持工程师) MCPD (微软认证开发专家) SCJP (SUN认证Java程序员) CISSP (信息系统安全认证专家) CompTIA A+认证 ...

  8. 基本SQL语句练习之SELECT

    一.SQL Plus连接sqlplus:以命令行方式连接数据库sqlplusw:以窗口登录方式连接数据库conn sys/password as sysdba;show userselect * fr ...

  9. ASP.NET MVC Controller接收ajax post方式发送过来的json对象或数组数据

    本例旨在说明我的一种Controller接收ajax提交(POST)过来的json对象或数组信息的方式,感觉应该有更好的方式,欢迎提出宝贵意见. JSON.stringify(jsonObj)不支持I ...

  10. 莫队算法学习笔记【BZOJ2038:小Z的袜子】【SPOJ3267:D-query】

    很久以前傻乎乎地看来源奇怪的资料的时候被各种曼哈顿弄晕了. 然后现在学会的是分块方法.另新创一个分块方法. 让我们考虑这样一个区间询问问题…… 它有如下的性质: 0,n个数,Q个询问. 1,它没有修改 ...