解题报告
题意:
插队完的顺序。
思路:
倒着处理数据,第i个人占据第j=pos[i]+1个的空位。
线段树维护区间空位信息。
#include
#include
#include
using namespace std;
struct node {
int x,v;
} num[201000];
int sum[1000000],ans[201000];
void c...
分类:
其他好文 时间:
2014-08-11 21:34:33
阅读次数:
378
给n个区间,任意两个区间要么完全包含,要么相离。m个查询,每次输入一个整数,输出这个数属于哪个区间,如果有多个区间,选长度最小的...
分类:
其他好文 时间:
2014-08-11 21:31:53
阅读次数:
187
bnu36905 Nested Segments
离散化+线段树区间更新
也可以用离散化+set(或双向链表)
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#...
分类:
其他好文 时间:
2014-08-11 21:31:03
阅读次数:
239
bnu36907 Subpalindromes
字符串hash+线段树
题意:给一个字符串(
1)将指定位置的字符改为c
2)询问l-r的子串,是否是回文串。
解法 :区间维护pl和pr,表示从左到右的hash和从右到左的hash,然后在up和query中合并区间,最后判断pl和pr是否相等即可。
#include
#include
#include
#include
#inc...
分类:
其他好文 时间:
2014-08-11 21:29:52
阅读次数:
301
题目大意:
n个人的编号是从1 - n ,现在他们无序的站成一排。
第 id 号人和 id-1 id +1 号人是朋友,
朋友之间可以组成group。
一个group的值等于他们人数的平方。
然后有m次询问,问给出的l r 之间能构成group值的和的最大值的group数。
思路分析:
首先,我们面临着假设你知道这个区间有多少个group 你能知道得到最大值的时候grou...
分类:
其他好文 时间:
2014-08-11 21:25:22
阅读次数:
315
There is one last gate between the hero and the dragon. But opening the gate isn't an easy task.
There were n buttons list in a straight line in front of the gate and each with an integer on it. Like...
分类:
其他好文 时间:
2014-08-11 21:22:33
阅读次数:
341
线段树研究了两天了,总算有了点眉目,今天也把落下的题,补了一下。 贴一份线段树模板
线段树的特点:
1. 每一层都是区间[a, b]的一个划分,记 L = b - a
2. 一共有log2L层
3. 给定一个点p,从根到叶子p上的所有区间都包含点p,且其他区间都不包含点p。
4. 给定一个区间[l; r],可以把它分解为不超过2log2 L条不相交线段的并。
总结来说:...
分类:
其他好文 时间:
2014-08-11 21:22:22
阅读次数:
528
比赛的时候 在Y , 以为是两个之间取最大, 然后给取出来得最大取个最小,后来发现
7
0 3 6 7 12 14 18
这组案例 应该跑出2.5 的 而那样Y 出不来小数给跪了.
后来在hack 的时候 看到很多二分的选手居然没被X; 这题二分是不行的...
比如说 这组案例
3
0 1 3 4
跑出来应该是2
2 符合案例 1.5比2 小但是不符合 所以答案不是线性关系的 所以不能二分来做.
后来看题解看到有人暴力. O(n*n);
这就要首先判断出,答案必须是某段区间或...
分类:
其他好文 时间:
2014-08-11 18:06:12
阅读次数:
250
http://acm.fzu.edu.cn/problem.php?pid=2171
线段树模板题,成段增减,区间求和。
思路:先查询,后更新。
#include
#define lson l , m ,rt << 1
#define rson m+1 , r , rt << 1 | 1
const int maxn = 100002;
int add[maxn << 2];
in...
分类:
其他好文 时间:
2014-08-11 18:01:42
阅读次数:
214
POJ 2796 Feel Good题意:给出一个长度为n(n<100000)的序列,求出一个子序列,使得这个序列中的最小值乘以这个序列的和的值最大。思路:枚举每一个点,然后算出以这个点为最小值的区间能向左向右扩展到哪里,然后选择最优的就行。SOJ3085: windy's cake V题意:和PO...
分类:
其他好文 时间:
2014-08-11 17:35:32
阅读次数:
578