codeforces 367B
来源:互联网 发布:特步官方旗舰店淘宝 编辑:程序博客网 时间:2024/05/21 18:00
题目链接:
http://codeforces.com/contest/367/problem/B
题解:
双端队列直接维护(原来map可以直接相等,这里学到了。。。)
代码:
#include <map>#include <cmath>#include <deque>#include <vector>#include <cstdio>#include <cstring>#include <vector>#include <algorithm>using namespace std;#define inf 0x3f3f3f3f#define met(a,b) memset(a,b,sizeof(a))const int maxn = 2e5+10;int a[maxn],b[maxn];map<int,int>mp,np;vector<int>pos;int n,m,p;int main(){ scanf("%d%d%d",&n,&m,&p); for(int i=1;i<=n;i++) scanf("%d", &a[i]); for(int i=1;i<=m;i++) { scanf("%d",&b[i]); mp[b[i]]++; } for(int i=1;i<=p;i++) { deque<int>q; np.clear(); for(int j=i;j<=n;j+=p) { q.push_back(j); np[a[j]]++; if(q.size()>m) { int k=q.front(); q.pop_front(); np[a[k]]--; if(np[a[k]]==0) np.erase(a[k]); } if(np==mp) pos.push_back(q.front()); } } sort(pos.begin(),pos.end()); int len=(int)pos.size(); printf("%d\n",len); for(int i=0;i<len;i++) { printf("%d",pos[i]); if(i!=len-1) printf(" "); else printf("\n"); }}
阅读全文
0 0
- Codeforces 367B
- codeforces 367B
- codeforces-367#B. Interesting drink
- codeforces B
- codeforces B
- codeforces B
- codeforces B
- CodeForces 367B. Sereja ans Anagrams
- Sereja ans Anagrams - CodeForces 367B 水题
- Codeforces Round #367 (Div. 2) A、B
- Codeforces #367 B. Interesting drink(二分)
- Codeforces Round #367 (Div. 2) B
- CodeForces 367B Sereja ans Anagrams
- codeforces 367B Sereja ans Anagrams
- CodeForces 626B CodeForces 626B【暴力】
- CodeForces 841B (B) 博弈
- codeforces 134B
- codeforces#98 b
- 如何修改虚拟机的Linux的ip地址
- 输入整形数组,数组里有正数也有负数,数组中一个或连续的多个整数组成数组的子数组,求所有子数组中和的最大值 ,例如输入的数组为{1,-2,3,10,-4,7,2,-5}和最大的子数组为{3,10,
- innerHTML和innertext的区别
- 最大连续子序列和
- 初始 RPC 框架
- codeforces 367B
- 神经网络 ——一个很好的解释以及简单实现 Implementing a Neural Network from Scratch in Python – An Introduction
- 第3章 栈和队列综合习题(leetcode+vjudge)
- Codeforces Round #438 868A/B/C
- 原声js鼠标滚一次一屏
- 安装zabbix前端时的 check of pre-requisites 问题
- C++ 接口(抽象类)
- LinkedList-二叉树遍历
- Big Christmas Tree POJ