2011年7月10日

poj-2828 Buy Tickets ***

摘要: 线段树//2828View Code /* * [这段话转的。。] * 如果我们从头开始一次做的话,无论是用链表还是数组,肯定会超时(链表寻址时间长,数组移位时间长。)。 * 所以要用一个快速的方法直接找到位置。但是换个角 度,如果我们反过来排,那样的话,我们就知道他所在的 * 精确位置!把存储的结构想象成是链表,插队的人插入后,把他所在的位置从链表中屏蔽掉,然后在新的链 表种 * 继续这样存,这样的话我们就得到了我们想要的顺序! * * 按照这种思想,可以用线段树实现。。。 * */#include <cstdio>using namespace std;const int MA 阅读全文

posted @ 2011-07-10 16:41 龙豆 阅读(469) 评论(0) 推荐(0)

poj-2528 Mayor's posters

摘要: 离散化 + 线段树坐标按从小到大排序,再构造映射。。View Code 1 //color=0表示未着色或为杂色 2 3 #include <cstdio> 4 #include <cstring> 5 #include <algorithm> 6 using namespace std; 7 8 const int MAXN = 40000 + 5; 9 const int MAX_R = 10000000 + 5; 10 11 int n, ans; 12 bool vis[MAXN] = {}; 13 struct SData{ //记录数据 14 i 阅读全文

posted @ 2011-07-10 14:06 龙豆 阅读(254) 评论(0) 推荐(0)

导航