acm
liuwq012
以前的博客:http://weiqingliu.iteye.com/
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
hdu 1423 Greatest Common Increasing Subsequence 题解
[code="C++"]#include #include #include #include #include using namespace std; int dp[550]; int T; int a[550],b[550]; int main() { scanf("%d",&T); int m,n; while(T--) ...原创 2015-07-25 20:38:11 · 259 阅读 · 0 评论 -
zoj 1558 背包
[code="C++"] #include using namespace std; int num[8],dp[10000+10]; int cmp(int x,int y) { return x>y; } int main() { int t; scanf("%d",&t); while(t--) { for...原创 2015-11-09 16:18:18 · 156 阅读 · 0 评论 -
poj 2985 并查集+树状数组求第k大数
[code="C++"] #include #include #define lowbit(i) i&(-i) #define maxn 300000 using namespace std; int a[maxn],c[maxn],p[maxn]; int fd(int x) { return x==p[x] ? x :fd(p[x]); } void upda...原创 2015-11-05 16:53:13 · 208 阅读 · 0 评论 -
hihocoder 1078 线段树区域更新
[code="C++"] #include #include #include using namespace std; #define M 1000005 struct tree{ int left,right,sum,lazy; }; tree g[M]; int map[M]; void pushDown(int i) { if(g[i].lazy) {...原创 2015-11-05 15:17:37 · 149 阅读 · 0 评论 -
poj 3984 bfs+栈的使用
[code="C++"] #include #include #include #include #include using namespace std; int dir[]={-1,0,1,0}; int dil[]={0,-1,0,1}; int num[6][6]; int visit[6][6]; int d[30]; struct node { ...原创 2015-11-03 21:01:34 · 205 阅读 · 0 评论 -
kmp裸模版 poj 3461
[code="C++"] #include #include using namespace std; const int maxn = 1000000+10; char s[maxn],t[maxn]; int next[maxn]; int m,n,k,l,i,T; void get_next(char str[]) { memset(next,0,size...原创 2015-11-03 19:01:13 · 191 阅读 · 0 评论 -
hdu 5510 Bazinga 思路详解 kmp +思维
[size=large]来一发代码,先前后两两比较,如果前一个串是后一个串的字串,那他就是没必要的,假设第i个串是i+1的子串,如果在后面循环比较中,如果第i+1个串是后面串的子串,那i个串就没有比的必要了,如果第i+1不是后面串的子串,直接结束循环,查找结束,得出结果[/size] [code="C++"] #include int next[10005]; int T; c...原创 2015-11-01 19:32:41 · 196 阅读 · 0 评论 -
neu 1438 树状数组求逆序数
[code="C++"] #include using namespace std; #define lowbit(i) i&(-i) const int N = 1000000 +10; int n,m,k,l,r; int a[N]; int getsum(int i) { int xx = 0; while(i>0) { xx...原创 2015-10-30 20:17:38 · 174 阅读 · 0 评论 -
poj 3468 树状数组
[color=darkred][u]http://kenby.iteye.com/blog/962159[/u][/color] ///我只想存个代码,思路来源解法都是上面那个网站看的 [code="C++"]#include #include using namespace std; const int N = 100000+10; long long det[N],num[...原创 2015-10-30 19:10:21 · 237 阅读 · 0 评论 -
hdu 1556 Color the ball 树状数组思路分析
[align=left][size=medium][color=red]网上很多博客都只给了代码,这对于很多刚接触树状数组的人来说往往一头雾水。我说一下主要思路:你每次更新一个点的时候(加一个数),后面所有的点的前缀和都会相应的加上这个数,这其实就相当于这个数受了这个点影响,你每次画一个点的时候,其实就相当于画了它后面所有的点,然后你把那些不必要画的点受的影响减回来就行[/color][/size...原创 2015-10-30 18:47:02 · 197 阅读 · 0 评论 -
树状数组求区间最值 hdu 1754
[size=large][color=red]原理:求和时c数组存的是相应区间的和,而在这c数组(mkx数组)求的是相应区间的最大值[/color][/size] [code="C++"]#include using namespace std; const int N = 400000+100; int n,m,k,l,r; int a[N]; int mkx[N],num[...原创 2015-10-29 16:00:45 · 367 阅读 · 0 评论 -
hnu Cent Saving
代码如下:注释部分为思路讲解 [code="C++"] ///hnu Cent Saving #include #include #include using namespace std; const int N = 2000, D = 20; const int infty = 0xfffffff; int Prize[N]; int Cost[N+1][...原创 2015-08-03 09:12:23 · 221 阅读 · 0 评论 -
uva 129 困难串
因为在递归的过程中,总是选择最小的i,所以最先求到的解肯定是字典序最小的,我觉得这也是这道题用这个算法的原因,因为我觉得这个算法对减时没有什么卵用 :wink: [code="C++"] #include #include #include using namespace std; int L,n,cnt; int s[1010]; int dfs(int cur)...原创 2016-03-19 20:05:43 · 196 阅读 · 0 评论
分享