摘要: 题目链接看了别人思路,逆序插入,然后就会发现只要为留出pos[i]个位置就行了。树状数组+二分求下界就好了。 1 #include <stdio.h> 2 #include <string.h> 3 #include <algorithm> 4 #include <iostream> 5 using namespace std; 6 #define N 200011 7 int pos[N]; 8 int p[N],n; 9 struct node10 {11 int val;12 int id;13 }num[N];14 int lowbit( 阅读全文
posted @ 2013-06-03 16:06 Naix_x 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 题目链接根据区间更新的模版改改。线段树真的很不熟悉,交了很多次。 1 #include <stdio.h> 2 #include <string.h> 3 #include <iostream> 4 using namespace std; 5 #define N 100001 6 #define LL __int64 7 int p[4*N],lz[4*N]; 8 void pushup(int rt) 9 {10 p[rt] = p[rt<<1]|p[rt<<1|1];11 }12 void pushdown(int rt)13 阅读全文
posted @ 2013-06-03 10:38 Naix_x 阅读(166) 评论(0) 推荐(0) 编辑