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 ...
随机推荐
- mysql redo log
mysql> show variables like '%innodb_log_file_size%'; +----------------------+-----------+ | Varia ...
- codevs1033 蚯蚓的游戏问题
题目描述 Description 在一块梯形田地上,一群蚯蚓在做收集食物游戏.蚯蚓们把梯形田地上的食物堆积整理如下: a(1,1) a(1,2)…a(1,m) a(2,1) a(2,2) a(2 ...
- HDU_2031——十进制转换成R进制
Problem Description 输入一个十进制数N,将它转换成R进制数输出. Input 输入数据包含多个测试实例,每个测试实例包含两个整数N(32位整数)和R(2<=R<=1 ...
- Linux下安装GCC5.3.0(亲测有效)
对于linux小白来说,只需要先知道怎么安装,至于为什么等学了linux再说吧..知识不系统的坏处啊! 首先,一般ubuntu上都预装了低级版本的Gcc,完全可以应付刷OJ时的C+Class+STL的 ...
- Contest - 2014 SWJTU ACM 手速测试赛(2014.10.31)
题目列表: 2146 Problem A [手速]阔绰的Dim 2147 Problem B [手速]颓废的Dim 2148 Problem C [手速]我的滑板鞋 2149 Problem D [手 ...
- nova-network
nova network-create demo-net --bridge br100 --multi-host T --fixed-range-v4 192.168.3.0/26 192.168.3 ...
- Hello,world,l'm coming!
#include<studio.h> int main() { printf("Hello,Word!" l'm coming\n"); return0; }
- VB.NET入门基础
众所周知,Visual Basic.NET是由Visual Basic发展而来,这两者之间的升级使得Visual Basic语言发生了革命性的变革,使得由基于对象编程的Visual Basic过渡到了 ...
- android View各属性详解
一.有8个直接子类:AnalogClock, ImageView, KeyboardView, ProgressBar, SurfaceView, TextView, ViewGroup, ViewS ...
- Ubuntu网络管理
1.重启NetworkManager service network-manager stop rm /var/lib/NetworkManager/NetworkManager.state serv ...