http://codeforces.com/contest/368/problem/D

  1. #include <cstdio>
  2. #include <cstring>
  3. #include <map>
  4. #include <vector>
  5. #include <algorithm>
  6. #define maxn 300000
  7. #define LL long long
  8. using namespace std;
  9.  
  10. int n,m,p;
  11. LL a[maxn],b[maxn];
  12. vector<int>g;
  13.  
  14. int main()
  15. {
  16. while(scanf("%d%d%d",&n,&m,&p)!=EOF)
  17. {
  18. for(int i=; i<n; i++)
  19. {
  20. scanf("%lld",&a[i]);
  21. }
  22. for(int i=; i<m; i++)
  23. {
  24. scanf("%lld",&b[i]);
  25. }
  26. for(int i=; i<p&&i+(LL)(m-)*p<n; i++)
  27. {
  28. map<int,int>q;
  29. for(int j=; j<m; j++)
  30. {
  31. q[b[j]]++;
  32. }
  33. int c=i;
  34. for(int j=; j<m; j++)
  35. {
  36. q[a[c]]--;
  37. if(q[a[c]]==)
  38. {
  39. q.erase(a[c]);
  40. }
  41. c+=p;
  42. }
  43. for(int j=i; ; j+=p,c+=p)
  44. {
  45. if(!q.size()) g.push_back(j+);
  46. if(c>=n) break;
  47. if(--q[a[c]]==) q.erase(a[c]);
  48. if(++q[a[j]]==) q.erase(a[j]);
  49. }
  50. }
  51. sort(g.begin(),g.end());
  52. printf("%d\n",g.size());
  53. for(int i=; i<(int)g.size(); i++)
  54. {
  55. printf("%d ",g[i]);
  56. }
  57. printf("\n");
  58. }
  59. return ;
  60. }

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. mysql redo log

    mysql> show variables like '%innodb_log_file_size%'; +----------------------+-----------+ | Varia ...

  2. codevs1033 蚯蚓的游戏问题

    题目描述 Description 在一块梯形田地上,一群蚯蚓在做收集食物游戏.蚯蚓们把梯形田地上的食物堆积整理如下: a(1,1)  a(1,2)…a(1,m) a(2,1)  a(2,2)  a(2 ...

  3. HDU_2031——十进制转换成R进制

    Problem Description 输入一个十进制数N,将它转换成R进制数输出.   Input 输入数据包含多个测试实例,每个测试实例包含两个整数N(32位整数)和R(2<=R<=1 ...

  4. Linux下安装GCC5.3.0(亲测有效)

    对于linux小白来说,只需要先知道怎么安装,至于为什么等学了linux再说吧..知识不系统的坏处啊! 首先,一般ubuntu上都预装了低级版本的Gcc,完全可以应付刷OJ时的C+Class+STL的 ...

  5. Contest - 2014 SWJTU ACM 手速测试赛(2014.10.31)

    题目列表: 2146 Problem A [手速]阔绰的Dim 2147 Problem B [手速]颓废的Dim 2148 Problem C [手速]我的滑板鞋 2149 Problem D [手 ...

  6. nova-network

    nova network-create demo-net --bridge br100 --multi-host T --fixed-range-v4 192.168.3.0/26 192.168.3 ...

  7. Hello,world,l'm coming!

    #include<studio.h> int main() { printf("Hello,Word!" l'm coming\n"); return0; }

  8. VB.NET入门基础

    众所周知,Visual Basic.NET是由Visual Basic发展而来,这两者之间的升级使得Visual Basic语言发生了革命性的变革,使得由基于对象编程的Visual Basic过渡到了 ...

  9. android View各属性详解

    一.有8个直接子类:AnalogClock, ImageView, KeyboardView, ProgressBar, SurfaceView, TextView, ViewGroup, ViewS ...

  10. Ubuntu网络管理

    1.重启NetworkManager service network-manager stop rm /var/lib/NetworkManager/NetworkManager.state serv ...