先对原串分组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. linux下定时器介绍2--timer_create等函数集的使用示例

    程序1:采用新线程派驻的通知方式 程序2:通知方式为信号的处理方式 #include <stdio.h>#include <time.h>#include <stdlib ...

  2. .net基础初学Android

    第一阶段:Java面向对象编程 1.Java基本数据类型与表达式,分支循环. 2.String和StringBuffer的使用.正则表达式. 3.面向对象的抽象,封装,继承,多态,类与对象,对象初始化 ...

  3. 工作常用shell集合

    <1>日志回滚案例======>[root@localhost test]# cat hbase.sh hbase_rotate_log ()       {    log=$1;  ...

  4. shell 数组基础->

    数组其实也算是变量, 传统的变量只能存储一个值, 但数组可以存储多个值. 普通数组:只能使用整数 作为数组索引 [有序 0 1 2 3 4 ]关联数组:可以使用字符串 作为数组索引 [无序 name ...

  5. mac idea内存溢出

    VM options: -mx2048m -XX:MaxPermSize=2048m -Drebel.spring_plugin=true -Drebel.hibernate_plugin=true

  6. 蛮力法解决0_1背包问题新思路-——利用C语言位域类型

    废话不说了,直接上代码 #include<stdio.h> #include<math.h> #define N 5 //物品种类数目 #define CAPACITY 6 / ...

  7. JMeter接口&性能测试

    JMeter接口测试 目前最新版本发展到5.0版本,需要Java7以上版本环境,下载解压目录后,进入\apache-jmeter-5.0\bin\,双击ApacheJMeter.jar文件启动JMem ...

  8. 20155225 实验二《Java面向对象程序设计》实验报告

    20155225 实验二<Java面向对象程序设计>实验报告 一.单元测试 三种代码 知道了伪代码.产品代码.测试代码的关系和用途,并根据老师的例子,按测试代码调试了产品代码. 值得注意的 ...

  9. TeamViewer的下载地址,低调低调

    https://github.com/cary-zhou/TeamViewer13-Crack

  10. jsonrpc.js -- 原生js实现 JSON-RPC 协议

    很早以前就涉及到多端远程调用 api的设计,那时候自己设计了个消息传递回调过程.最近了解了JSON-RPC协议,更正规,就可以自己实现下.逻辑也不复杂,没有限制底层消息传递的方式,可以应用到更多的场景 ...