cf D. Sereja ans Anagrams
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的更多相关文章
- 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 ...
- Sereja ans Anagrams 优先队列控制
Sereja has two sequences a and b and number p. Sequence a consists of n integers a1, a2, ..., an. Si ...
- Sereja ans Anagrams
Codeforces Round #215 (Div. 1) B:http://codeforces.com/problemset/problem/367/B 题意:给你两个序列a,b,然后给你一个数 ...
- 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+ ...
- CF 314C Sereja and Subsequences(树状数组)
题目链接:http://codeforces.com/problemset/problem/314/C 题意:给定一个数列a.(1)写出a的不同的所有非下降子列:(2)定义某个子列的f值为数列中各个数 ...
- 【CF】Sereja and Arcs
#include <bits/stdc++.h> #define llong long long using namespace std; const int N = 1e5; const ...
- cf C. Sereja and Algorithm
http://codeforces.com/contest/368/problem/C 从左向右记录从1位置到每一个位置上x,y,z的个数.然后判断在l,r区间内的x,y,z的关系满不满足abs(x- ...
- cf B. Sereja and Suffixes
http://codeforces.com/contest/368/problem/B 从后往前找一遍就可以. #include <cstdio> #include <cstring ...
- 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 ...
随机推荐
- 精美实用的jQuery插件精选
jQuery的确是一款相当强大的Javascript框架,同时jQuery的插件就多入牛毛,如果你善于收集,那么你在写前端页面的时候肯定会更加方便.本文精选了一些精美实用的jQuery插件供大家参考. ...
- 探讨c#中的unchecked是什么意思,起什么作用?
Checked与Unchecked 对于因为整数类型参与算术操作和类型转换时产生的“溢出异常”——System.OverflowException,在某些算法来讲不算真正的“异常”,相反这种溢 ...
- CATransform3D 讲解
最近看到一个3D动画效果,决定认真就研究一下.从网上看到很多介绍,下面详细的讲解一下CATransform3D CATransform3D结构成员的意义. structCATransform3D { ...
- ubuntu14.04 install flow.
打开虚拟机,点击菜单上的“文件”,选择新建虚拟机,如下图所示: 注释:这里选择自定义安装,点击下一步. 这里我的虚拟机版本最新是10的,就选最新的,然后点击下一步,如下图: 这里选择要安装的Ubunt ...
- SQL数值函数
/*abs(n)返回参数n所指定数值的绝对值(如果参数值为NULL,则返回结果为NULL,下同).*/--SELECT ABS(-3.14) FROM DUAL; --3.14 /*round(n[, ...
- script 表单验证
表单验证:一.非空验证:1.内容是不是空的.判断值的长度是不是0.length属性.压缩空格的函数. 2.内容是不是改变了. 二.对比验证:1.验证两个控件值的关系(相同,大小) 2.验证控件的值与某 ...
- html5.边框属性相关知识点
border-left 定义左边框 border-top 定义上边框 border-right 定义有边框 border-bottom 定义下边框 边框样式: dotted 边框线为点状虚线 dash ...
- Android(性能)
■ 数据传输 对象和字节流之间的转换 为什么要转? 持久化(装逼说法,JVM非运行的场合),他进程(装逼说法,其他机器JVM,不同的JVM) Parcelable和Serializable 初衷: P ...
- Spring MVC 之 Hello World
1.新建一个动态web项目 2.web.xml编写 <?xml version="1.0" encoding="UTF-8"?> <web-a ...
- hdu5353
模拟,,, 每个人有一些糖果,每两个人之间只能给一个糖果,问最后是否能让所有人的糖果数量相同,只要确定一个糖果的流向其他的就能够确定. 马虎了,卡了好几天,心塞塞的... #include<io ...