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 ...
随机推荐
- curl 提交请求
http://forums.phpfreaks.com/topic/194255-curl-sending-array-as-post-value/ http://www.cnblogs.com/ch ...
- HDOJ 1058 Humble Numbers(打表过)
Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The ...
- 转载-常用API接口签名验证参考
原文地址: http://www.cnblogs.com/hnsongbiao/p/5478645.html 写的很好,就做个笔记了.感谢作者! 项目中常用的API接口签名验证方法: 1. 给app分 ...
- SPOJ--K-query (线段树离线) 离线操作解决一些问题
K-query Given a sequence of n numbers a1, a2, ..., an and a number of k- queries. A k-query is a tri ...
- MD中bitmap源代码分析--数据结构
本篇分析bitmap的数据结构的设计,并基于此分析bitmap的工作机制. 为了后面更清楚的理解,先有个总体印象,给出整体的结构图: 在下面的描述中涉及到的内容可以对照到上图中相应部分,便于理解. 首 ...
- cocos2d-x游戏开发(十七)NDK+ant编译暗黑世界
个人原创,欢迎转载http://blog.csdn.net/dawn_moon/article/details/12308967 9秒论坛的客户端暗黑世界,ios已经跑过了,今天搞了一下安卓的,记录一 ...
- CSS初始化-KISSY CSS Reset 1.0
代码 /* KISSY CSS Reset 理念:1. reset 的目的不是清除浏览器的默认样式,这仅是部分工作.清除和重置是紧密不可分的. 2. reset 的目的不是让默认样式在所有浏览器下一致 ...
- C++编程规范之20:避免函数过长,避免嵌套过深
摘要: 短胜于长,平胜于优,过长的函数和嵌套过深的代码块的出现,经常是因为没能赋予一个函数以一个紧凑的职责所致,这两种情况通常都能够通过更好的重构予以解决. 每个函数都应该顾其名而能知其义,易于理解的 ...
- Label 添加表情图片
// 添加表情 NSTextAttachment *attch = [[NSTextAttachment alloc] init]; // 表情图片 attch.image = [UIImage im ...
- Heritrix源码分析(十五)
开博客以及建立Heritrix 群有一段时间了(这里谢谢大家的关注),这篇博客将整理这段时间所遇到的问题.同时由于自己从今年5月份开始就不怎么接触Heritrix,很多东西开始遗忘(不过里面思想没忘) ...