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 ...
随机推荐
- Android 查看是否有存储卡插入
String status=Environment.getExternalStorageState(); 2 3 if ( status.equals ( Enviroment.MEDIA_MOU ...
- Function对象
Function对象是js中很重要的一个元素,js中所有自定义的函数都是Function对象,所以String,Number,Boolean,function等都是Function对象.所以,在使用t ...
- tomcat主目录
简单显示天气预报js 代码
- CSS3: box-sizing 属性的简单认识
定义和用法: box-sizing 属性允许您以特定的方式定义匹配某个区域的特定元素. 默认值:content-box; 继承性:无: css版本:css3 语法:box-sizing: conten ...
- Eclipse 4.2 + Tomcat 7.x + JDK 7 搭建Java Web开发环境
1. 准备工具 Eclipse 4.2 (到官网下载:http://www.eclipse.org/downloads/ 要下载Eclipse IDE for Java EE Developers ...
- mac os使用lsusb命令和连接未知的Android设备
今天在mac上连接一个android设备发现连不上,adb devices看不到设备.于是想用lsusb命令看下,结果发现Mac居然没有这个命令,于是网上搜了下.发现了以下的命令system_prof ...
- 查看android进程信息
打开adb shell.直接ps命令 假设查看某特定进程,比方<圣火英雄传>.用grep过滤 各列參数意义: USER 进程当前用户: PID Pro ...
- QLCDNumber设置背景色和显示数字颜色
只看楼主 倒序阅读楼主 发表于: 2013-10-22 //LCD时间显示 QLCDNumber *m_pLcdTime = new QLCDNumber(thi ...
- jquery之onchange事件
$(function(){ $("#opreateHtml").window("close"); $("#deliveryGrid").da ...
- 路由器密码破解工具 Hydra 7.5
之前只在 Browser 中保存了路由管理密码,无奈升级时管理的密码丢失了,又不想重新设置,所以尝试破解登录密码. 使用破解工具 Hydra 7.5. # hydra -l username -x : ...