HDU 4441 Queue Sequence】的更多相关文章

Problem Description There's a queue obeying the first in first out rule. Each time you can either push a number into the queue (+i), or pop a number out from the queue (-i). After a series of operation, you get a sequence (e.g. +1 -1 +2 +4 -2 -4). We…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4441 题意:一个数列,三种操作:(1)插入:找到没在当前数列中的最小的正整数i,将其插在位置p之后,并将-i插入某个位置使得满足先进先出(i表示进,-i表示出),这个位置尽量靠右:(2)删除:删掉数字i以及-i:(3)询问:查询i和-i之间的数字的和. 思路:对于没在数列中的数字可以用一个set直接维护.i的插入是正常的splay操作.对于-i的插入,我们首先找到i之前有几个正数,比如有x个,那么-…
http://acm.hdu.edu.cn/showproblem.php?pid=4441 题意:对于一个序列,每次有三种操作   insert pos  表示在pos插入一个数,这个数是最小的正数没有在序列中出现的.而且还要在某个位置插入他的相反数,使得这个序列满足队列的出入顺序(正表示进,负表示出)   remove num 表示在序列中把num以及-num两数去掉   query num 把num与-num之间的数求和输出 这题我本来实在是没有思路,看起来像维护一个线段树,这样求和好办,…
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-size: 10.5000pt } h1 { margin-top: 5.0000pt; margin-bottom: 5.0000pt; text-align: center; font-family: 宋体; color: rgb(26,92,200); font-weight: bold; fo…
HDU 1711 Number Sequence(数列) Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) [Description] [题目描述] Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N…
HDU 1005 Number Sequence(数列) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) [Description] [题目描述] A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. Given A, B, an…
HDU 5860 Death Sequence(递推) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=5860 Description You may heard of the Joseph Problem, the story comes from a Jewish historian living in 1st century. He and his 40 comrade soldiers were trapped in a cave…
HDU 1560 DNA sequence(DNA序列) Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)   Problem Description - 题目描述 The twenty-first century is a biology-technology developing century. We know that a gene is made of DNA. Th…
HDU 1005 Number Sequence(数论) Problem Description: A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. Given A, B, and n, you are to calculate the value of f(n).   Input The input consists of multipl…
HDU 1711 Number Sequence (字符串匹配,KMP算法) Description Given two sequences of numbers : a1, a2, ...... , aN, and b1, b2, ...... , bM (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make aK = b1, aK+1 = b2, ...... , aK+M…