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

码力不行啊... 错误记录: 171行后面对find2的使用错误,原来写的是p=find2(rt,p1),然后再加上一句能过样例但很假的特判 事实上,现在是要寻找最大的j,使得d2[1..j-1]=p1-1 而find2返回的是最大的j,使得d2[1..j]<=p1,因此要这么用 #pragma GCC optimize("Ofast") #include<cstdio> #include<algorithm> #include<cstring>…
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…
Q - Play With Sequence HDU - 3971 这个题目是一个线段树,比较特别的线段树,就是c询问一定次数之后重新排序建树来优化减低复杂度. 第一次碰到这种题目有点迷. 这个题目写还是很好写的,就是重新排序建树的位置不太好找. 不过可以知道的是,这是更新花费时间和排序花费时间的一个平衡,这个是一个二次函数,这个二次函数的最低点可以自己测出来. 现在可能有点听不懂,写完代码就很好理解了, 我测的每隔2000次C的操作就重新建树排序是最优的. 800,1000,2200,3000…
题目链接: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之间的数求和输出 这题我本来实在是没有思路,看起来像维护一个线段树,这样求和好办,…
DNA sequence Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4217    Accepted Submission(s): 2020 Problem Description The twenty-first century is a biology-technology developing century. We kno…
http://acm.hdu.edu.cn/showproblem.php?pid=1711 Number Sequence Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 16080    Accepted Submission(s): 7100 Problem Description Given two sequences of n…
链接: http://acm.hdu.edu.cn/showproblem.php?pid=5400 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 875    Accepted Submission(s): 386 Problem Description A sequence b1,b2,⋯,bn are called (d1,d2)…
There is a special number sequence which has n+1 integers. For each number in sequence, we have two rules: ● a i ∈ 0,n0,n ● a i ≠ a j( i ≠ j ) For sequence a and sequence b, the integrating degree t is defined as follows("�" denotes exclusive or…
Number Sequence Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 24928    Accepted Submission(s): 10551 Problem Description Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1],…