先对原串分组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. 【codeforces】940F题解

    CF Round #466的最后一题,颇有难度,正解是带修改莫队算法. [题意] 给定一个长度为\(n\)的数组\(a\),并且要求执行\(q\)个操作,有两种不同的操作: ①询问一个区间\([l,r ...

  2. Wood Cut

    Given n pieces of wood with length L[i] (integer array). Cut them into small pieces to guarantee you ...

  3. JSONArray().fromObject(); 出现org.apache.catalina.core.StandardWrapperValve invoke错误的解决办法

    servlet: public void service(HttpServletRequest request, HttpServletResponse response) throws Servle ...

  4. python网络编程-线程队列queue

    一:线程queu作用 Python中,queue是线程间最常用的交换数据的形式. 队列两个作用:一个是解耦,一个是提高效率 二:语法 1)队列的类 class queue.Queue(maxsize= ...

  5. java基础30 List集合下的LinkedList集合

    单例集合体系: ---------| collection  单例集合的根接口--------------| List  如果实现了list接口的集合类,具备的特点:有序,可重复       注:集合 ...

  6. No.6 selenium学习之路之下拉框Select

    HTML中,标签显示为select,有option下拉属性的为Select弹框 1.Xpath定位 Xpath语法,顺序是从1开始,编程语言中是0开始

  7. 最后一面《HR面》------十大经典提问

    1.HR:你希望通过这份工作获得什么? 1).自杀式回答:我希望自己为之工作的企业能够重视质量,而且会给做得好的员工予以奖励.我希望通过这份工作锻炼自己,提升自己的能力,能让公司更加重视我. a.“我 ...

  8. thinkphp辅助方法,数据库操作

  9. java 学习网站

    http://how2j.cn/  教学网站 慕课视频下载网站 http://www.feemic.cn/mooc //慕课搜索和下载的网站http://www.soshoulu.com/tools/ ...

  10. Spring Boot整合JPA、Redis和Swagger2

    好久没有总结了,最近也一直在学习.今天就把spring boot与其它技术的整合做个小总结,主要是jpa.redis和swagger2.公司里有用到这些,整合起来也很简单. 首先,新建一个Spring ...