摘要: 考试时很诡异的考虑到了类似俄罗斯方块的情形,就像是天上不停的下高为h的俄罗斯方块,然后根据下面的方块高度来进行新的高度的判断。很容易想到DP方程,设第i个方块能达到的高度为F[i],有F[i]=max{F[i]+H[i]},其中1<=j<=i-1,H[i]为第i个方块的高度。判定第i,j个方块是否有重合部分只需分别对x和y坐标做判定即可。View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 struct data{ 4 int a,b,h,x,y 5 }a[1001]; 6 int f[1001],n,m, 阅读全文
posted @ 2012-02-26 22:02 ustc-acm 阅读(391) 评论(0) 推荐(0) 编辑
摘要: 这道题是一区间统计,注意炸弹炸的是线段,最后要求的是最大的损坏值D_max,最左的具有D_max的线段的左起点,和,最右的具有D_max的线段的右起点。因为是离线统计(废话,炸着炸药你就去修路啊~~),所以未必要用线段树全长 [0, len] 在数轴上。离散也就是 0, 1, … , len-1 ( n = [n, n+1] )101 5 26 9 2也就是[5, 6]无损把[a, b] +d拆成 [a, infinity] +d, [b,infinity] -d即可。O, 上面理解错了,还是理解成点【0,len】也就是len+1个点,对【a,b】操作就是对(b-a+1)个点操作2781797 阅读全文
posted @ 2012-02-26 17:21 ustc-acm 阅读(423) 评论(1) 推荐(0) 编辑
摘要: 题目大意:给出n条直线,求将x=a,x=b所围区域分成多少个小区域。思路:n条直线对应[a,b]区域内n条线段。按线段左端点排序,求右端点的逆序对。View Code 1 #include<iostream> 2 #include<stdio.h> 3 #include<string.h> 4 #include<algorithm> 5 #define MAX 31000 6 using namespace std; 7 typedef struct Line{ 8 int x,y; 9 };10 Line c[MAX];11 int f[MAX 阅读全文
posted @ 2012-02-26 14:49 ustc-acm 阅读(255) 评论(1) 推荐(0) 编辑
摘要: #include <iostream> int main() { std::cout <<"hello world!\n"; return 0; } 新随笔 -> 添加新随笔 -> "插入代码(推荐)"按钮 -> done 阅读全文
posted @ 2012-02-26 11:04 ustc-acm 阅读(135) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> int main() { std::cout <<"hello world!\n"; return 0; } 新随笔 —> 文章 —> 添加新文章 —> 插入代码 阅读全文
posted @ 2012-02-26 11:02 ustc-acm 阅读(76) 评论(0) 推荐(0) 编辑