andre_joy

导航

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 15 下一页

2012年8月3日

poj 2823

摘要: 地址:http://poj.org/problem?id=2823题意:n个数里面连续的k个数,找最大和最小的。mark:优先队列,不过要重载一下cmp函数。 也可以单调队列做。代码:#include <stdio.h>#include <string.h>#include <stdlib.h>int queue[1000010];int a[1000010];int m,n;void solve(int f){ int i,j,k; int fr,la; fr = la = 0; queue[la++] = 0; for(i = 1; i < m; 阅读全文

posted @ 2012-08-03 15:33 andre_joy 阅读(174) 评论(0) 推荐(0) 编辑

zoj 3471

摘要: 地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3471题意:n种气体,每两种碰在一起会产生能量,然后后者消失。自己不能跟自己撞。求产生的最大能量。mark:状态压缩dp。自己写的时候很忐忑,最后看解体报告发现跟自己思路一样,嘿嘿~代码:#include <stdio.h>#include <string.h>#include <stdlib.h>#define J1 (k|(1<<j))#define J2 (k&(1<<j))#define I 阅读全文

posted @ 2012-08-03 10:51 andre_joy 阅读(167) 评论(0) 推荐(0) 编辑

2012年8月2日

poj 1753

摘要: 地址:http://poj.org/problem?id=1753题意:黑白棋,翻动一个格子,周围相连的格子都翻转,问最少几次使所有棋子颜色相同。mark:正解高斯消元,第一次写,写了两天,终于理解并ac了~代码:#include <stdio.h>#include <string.h>int g[20][20];int min(int a, int b) {return a < b ? a : b;}int find(int i){ int j; for(j = i; j < 17; j++) if(g[j][i]) return j; return 0; 阅读全文

posted @ 2012-08-02 22:43 andre_joy 阅读(128) 评论(0) 推荐(0) 编辑

2012年7月29日

hdu 1160

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1160题意:给出反例,老鼠长的越胖,速度越慢的例子。mark:最长递增子序列。不过本题要求记录这段子序列,不能用传统的nlgn的算法,只能n*n的算法了。代码:#include <stdio.h>#include <string.h>#include <stdlib.h>typedef struct{ int pos; int w,s;}mice;typedef struct{ int pre; int sum;}dpp;mice m[1010];dpp dp[101 阅读全文

posted @ 2012-07-29 23:12 andre_joy 阅读(649) 评论(0) 推荐(0) 编辑

2012年7月27日

hdu 1494

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1494题意:中文……mark:dp[i][j]代表第i个时间段,有j数量的油,油的数量0~14.代码:#include <stdio.h>#include <string.h>#define N 0x3f3f3f3fint dp[2][15];int a[110][2];int min(int a, int b) {return a < b ? a : b;}int main(){ int l,n,min1; int i,j; while(~scanf("%d%d 阅读全文

posted @ 2012-07-27 22:07 andre_joy 阅读(157) 评论(0) 推荐(0) 编辑

hdu 1300

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1300题意:买珠宝。每种品种必须加上10个同等级珠宝的价钱,可以将低品种的并入高品种,这样可能可以减少价钱。求最小价钱。mark:dp。刚开始思路是小品种的往大品种上加,直到加不了。然后大部分数据可以过,不过显然是wa的。后来看解题报告用新思路做,数据设小了。。wa了。代码:#include <stdio.h>int min(int a, int b) {return a < b ? a : b;}int main(){ int dp[110], a[110][2]; int t, n 阅读全文

posted @ 2012-07-27 15:15 andre_joy 阅读(185) 评论(0) 推荐(0) 编辑

2012年7月26日

poj 1258

摘要: 地址:http://poj.org/problem?id=1258题意:把所有农场连起来的最小费用。mark:最简单的最小生成树。第一次写,代码比较乱~代码:#include <stdio.h>#include <string.h>const int N = 110;const int MAX = 100010;int vis[N],dis[N];int a[N][N];int min(int a, int b) {return a < b ? a : b;}int main(){ int n,ans,min1,f,sum; int i,j,k; while(~s 阅读全文

posted @ 2012-07-26 10:55 andre_joy 阅读(101) 评论(0) 推荐(0) 编辑

2012年7月25日

hdu 1025

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1025题意:上面n个点,下面n个点,然后在这2n个点之间随意连线,一个点只能被连一次,问最多有多少条线不交叉。mark:把上面点排序后,那么就转换成最大升序子序列的问题了。可以看看我上一篇博客~poj 3903代码:#include <stdio.h>#include <string.h>#include <stdlib.h>typedef struct{ int s,e;}city;city c[500010];int len;int d[500010];int c 阅读全文

posted @ 2012-07-25 15:48 andre_joy 阅读(549) 评论(0) 推荐(0) 编辑

poj 3903

摘要: 地址:http://poj.org/problem?id=3903题意:求最长上升子序列。mark:在网上学习一种O(nlgn)的算法,拿过来试验了一下。http://blog.sina.com.cn/s/blog_76344aef0100scyq.html代码:#include <stdio.h>int len;int a[100010];int d[100010];int find(int m){ int fr = 0, la = len-1, mid; while(fr <= la) { mid = (fr+la)/2; if(d[mid] ... 阅读全文

posted @ 2012-07-25 15:30 andre_joy 阅读(234) 评论(0) 推荐(0) 编辑

poj 1185

摘要: 地址:http://poj.org/problem?id=1185题意:中文……mark:经典的状态压缩dp。第一次写,在网上看别人解题报告看了好多,百度一下就有很多。 推荐一个解释很详细的解题报告http://apps.hi.baidu.com/share/detail/14572384 wa了好多次。特别是match函数那,有很多a,b为0的时候的临界情况。 ps:别人的代码不一定是正确的,我找了一篇ac代码,然后比对数据,结果发现他的数据不对。囧……代码:#include <stdio.h>#include <string.h>#define N 61int dp 阅读全文

posted @ 2012-07-25 00:08 andre_joy 阅读(144) 评论(0) 推荐(0) 编辑

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 15 下一页