UVA11996 Jewel Magic】的更多相关文章

思路 splay维护序列的hash值即可 因为有rev操作,还要维护反串的hash值 代码 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; unsigned long long my_pow[600000]; const int base=131; struct Node{ unsigned long long hashx,hashx_rev; int son[…
Jewel Magic UVA - 11996 这是一道用splay/非旋treap做的题(这里用的是非旋treap) 1/2/3是splay/非旋treap的常规操作.对于操作4,可以用哈希法求LCP.记hash(i,L)为子串[i,i+L-1](即第i个开始的L个)的hash值.记s[i]为序列第i位(编号从1开始),n为序列长度 如果通过某种方式做到能在O(logn)时间内取出一段子串的hash值,那么二分答案(即LCP长度x),可以在O(logn)时间内判一个x是否合法(如果hash(l…
题意:给定一个长度为n的01串,你的任务是依次执行如表所示的m条指令: 1 p c 在第p个字符后插入字符,p = 0表示在整个字符串之前插入2 p 删除第p个字符,后面的字符往前移3 p1 p2反转第p1到第p2个字符4 p1 p2输出从p1开始和p2开始的两个后缀的LCP. 析:对于前三个操作,splay 很容易就可以解决,但是对于最后一个操作,却不是那么容易,因为这是动态的,所以我们也要维护一个可以动态的,这就可以用Hash来解决,由于要翻转,所以要维护两个,一个正向的,一个反向的.在操作…
维护一个01序列,一共四种操作: 1.插入一个数 2.删除一个数 3.反转一个区间 4.查询两个后缀的LCP 用Splay或者Treap都可以做,维护哈希值,二分求LCP即可. 注意反转序列的时候序列的哈希值也会改变,因此需要维护正反两个哈希值,在交换左右儿子的时候顺便交换两个哈希值即可. 还有就是打标记的同时也要进行反转,不要等pushdown的时候再反转 #include<bits/stdc++.h> using namespace std; typedef unsigned long l…
#include <cstdio> #include <cstdlib> #include <iostream> #include <algorithm> #include <vector> using namespace std; typedef unsigned long long ull; ; ; ull xp[maxn]; int n, m; struct Node { Node* ch[]; int r, v, s; int val;…
Ceph 测试环境部署 本文档内容概要 测试环境ceph集群部署规划 测试环境ceph集群部署过程及块设备使用流程 mon节点扩容及osd节点扩容方法 常见问题及解决方法 由于暂时没有用到对象存储,所以暂时没有配对象存储的网关. ==回答:为什么docker里用到ceph?== 环境里面每台机器挂载了个1T的数据盘,为了充分利用集群里所有数据磁盘的空间,使用ceph构建分布式环境,将数据盘联合到一起,看成一个盘.当然,这个主要是ceph的快存储功能. 集群部署规划 主机角色规划 主机名 系统 内…
传送门 Harry And Magic Box Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 165    Accepted Submission(s): 64 Problem Description One day, Harry got a magical box. The box is made of n*m grids. Ther…
D. Magic Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Consider the decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal presentation of…
A magic index in an array A[0...n-1] is defined to be an index such that A[i] = i. Given a sorted array of distinct integers, write a method to find a magic index, if one exists, in array A. FOLLOW UP What if the values are not distinct? public int g…
介绍 在Python中,所有以"__"双下划线包起来的方法,都统称为"Magic Method",例如类的初始化方法 __init__ ,Python中所有的魔术方法均在官方文档中有相应描述,但是对于官方的描述比较混乱而且组织比较松散.很难找到有一个例子. 构造和初始化 每个Pythoner都知道一个最基本的魔术方法, __init__ .通过此方法我们可以定义一个对象的初始操作.然而,当调用 x = SomeClass() 的时候, __init__ 并不是第一个…