先对原串分组hash,查询就是看某一区间内是否出现某值.

可以每个值存一个集合,保存这个值出现的位置.(也可以建可持久化值域线段树)

map<int,set<int> >很省事...

(Yes写成了YES,狂WA)

 #include <cstdio>
#include <map>
#include <set>
#define N 1000010
#define Mod 9999990000001LL
#define Base 100000007LL
using namespace std; typedef unsigned long long dnt; int n, m, k;
int buf[N];
map<dnt,set<int> > mst; dnt hash( int *a ) {
dnt rt=;
for( int i=; i<k; i++ )
rt = (rt*Base + a[i]) % Mod;
return rt;
}
int main() {
scanf( "%d%d%d", &n, &m, &k );
for( int i=; i<=n; i++ )
scanf( "%d", buf+i );
for( int i=; i<=n; i++ ) {
mst[hash(buf+i)].insert(i);
}
for( int t=; t<=m; t++ ) {
int l, r;
scanf( "%d%d", &l, &r );
for( int i=; i<k; i++ )
scanf( "%d", buf+i );
r = r-k+;
dnt v = hash(buf);
map<dnt,set<int> >::iterator it = mst.find(v);
if( it==mst.end() || it->second.lower_bound(l)==it->second.upper_bound(r) )
printf( "Yes\n" );
else
printf( "No\n" );
}
}

bzoj hash+map+set的更多相关文章

  1. Hash Map (Hash Table)

    Reference: Wiki  PrincetonAlgorithm What is Hash Table Hash table (hash map) is a data structure use ...

  2. Implement Hash Map Using Primitive Types

    A small coding test that I encountered today. Question Using only primitive types, implement a fixed ...

  3. hdu1381 Crazy Search(hash map)

    题目意思: 给出一个字符串和字串的长度,求出该字符串的全部给定长度的字串的个数(不同样). 题目分析: 此题为简单的字符串哈hash map问题,能够直接调用STL里的map类. map<str ...

  4. [LeetCode] Repeated DNA Sequences hash map

    All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...

  5. Hash Map 在java中的解释及示例

    目录 HashMap在java中的应用及示例 HashMap的内部结构 HashMap的性能 同步HashMap HashMap的构造函数 HashMap的时间复杂度 HashMap的方法 1. vo ...

  6. Redis的增删改查 c# key value类型和hash map 类型

    using Newtonsoft.Json; using StackExchange.Redis; using System; using System.Collections.Generic; us ...

  7. 哈希表(Hash Map)

    今天第一次做Leetcode用到了散列表,之前学的数据结构的内容都忘了,正好趁热打铁补一补. 摘自其他博客的一个整合. 一.哈希表简介 数据结构的物理存储结构只有两种:顺序存储结构和链式存储结构(像栈 ...

  8. D. Zero Quantity Maximization(hash+map)

    题意:就是让c=a*x+b,给你一个a[],b[],让你尽可能多的让c[]=0,输出有多少. 思路:直接令c=0,则x=-b/a, 也就是一条直线,通过这样就用hash值使相同的k值映射到一起,使用了 ...

  9. hdu 4821 字符串hash+map判重 String (长春市赛区I题)

    http://acm.hdu.edu.cn/showproblem.php?pid=4821 昨晚卡了非常久,開始TLE,然后优化了之后,由于几个地方变量写混.一直狂WA.搞得我昨晚都失眠了,,. 这 ...

随机推荐

  1. Python标准库笔记(10) — itertools模块

    itertools 用于更高效地创建迭代器的函数工具. itertools 提供的功能受Clojure,Haskell,APL和SML等函数式编程语言的类似功能的启发.它们的目的是快速有效地使用内存, ...

  2. openjudge-NOI 2.5-1700 八皇后问题

    题目链接:http://noi.openjudge.cn/ch0205/1700/ 题解: 经典深搜题目…… #include<cstdio> ][]; int num; void pri ...

  3. C++中关于位域的概念

    原文来自于http://topic.csdn.net/t/20060801/11/4918904.html中的回复 位域 有些信息在存储时,并不需要占用一个完整的字节,   而只需占几个或一个二进制位 ...

  4. caffe卷积操作

  5. 排序与相关性(Sorting and Relevance)

    本文翻译自Elasticsearch官方指南的Sorting and Relevance一章的第一节. 原文地址:http://www.elastic.co/guide/en/elasticsearc ...

  6. VS Code折腾记 - (1)扯淡

    题外话 距离上篇介绍VSCode的文章已经过去四十多天,已经在正式项目作为主力开发工具了. 社区的发展非常快速,更新迭代够快,功能基本已经满足我所需了: 这个系列教程基于最新的vs code 1.8. ...

  7. CSS常见简写规则整理

    外边距(margin) margin-top margin-right margin-bottom margin-left 简写顺序为顺时针方向(上.右.下.左),如:margin: 1px 2px ...

  8. FlumeNG介绍及安装部署

    本节内容: Flume简介 Flume NG核心组件 Flume部署种类 Flume单机安装 一.Flume简介 Flume是一个分布式.可靠.高可用的海量日志聚合系统,支持在系统中定制各类数据发送方 ...

  9. jQuery类名添加click方法

    通过$("").jQuery为元素添加点击事件,在使用类的情况下,可以使用$(e.target).attr('title');获得被点击元素的属性值. 示例代码如下 $(" ...

  10. Linux下文件压缩与打包

    Linux常用压缩命令compresscompress压缩出来的文件的后缀是.Z,解压命令是ucompresscompress -c 文件 > 压缩后的文件名 ,选项-v显示压缩过程,选项-c的 ...