摘要: 1220又一神题啊 卡内存可以卡到这种地步 省得不行了开两个【N]数组 一个来记录前驱 一个存数 记录前驱的用unsigned short类型 最大可达65535 不过可以标记一下是否比这个数大 比它大的话就减去 求的时候再加上 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 100010 8 unsigned short p2[N]; 9 int p1[N];10 int stack[1010];11 int main()12 {13 int n,a,... 阅读全文
posted @ 2013-09-24 19:46 _雨 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 1671并查集 对于询问删除边之后的连通块 可以倒着加边 最后再倒序输出 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 100010 8 int p[N],father[N],a,b,f[N]; 9 int pp[N];10 struct node11 {12 int x,y;13 }ed[N];14 int find(int x)15 {16 if(father[x]!=x)17 father[x] = find(father[x])... 阅读全文
posted @ 2013-09-24 16:56 _雨 阅读(254) 评论(0) 推荐(0) 编辑
摘要: 1613高端的东西lower_bounder函数lower_bound()在first和last中的前闭后开区间进行二分查找,返回大于或等于val的第一个元素位置。如果所有元素都小于val,则返回last的位置,且last的位置是越界的然后用map 把数映射成容器 可以简单查询到每个数出现的最前和最后位置 再与给出的L,R相比较 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 #define N 7001010 map >t;11 v 阅读全文
posted @ 2013-09-24 15:36 _雨 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 1306URAL真是没水题 以为简单的排序就好了 ME 内存限制很紧 堆排序 或者 STL用堆排序做的 正好复习一下 都忘了 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 1250010 8 int a[N]; 9 void adjust(int i,int n)10 {11 int j;12 a[0] = a[i];13 j = 2*i;14 while(ja[j])17 j++;18 if(a... 阅读全文
posted @ 2013-09-24 09:23 _雨 阅读(221) 评论(0) 推荐(0) 编辑