摘要: //最基础的并查集 最小生成树 #include <stdio.h>#include <stdlib.h> const int MAX = 101;struct E{ int x,y,weight;};E edge[5001];int father[MAX];int cmp(const void *d1, const void *d2){ return (*(E*)d1).weight - (*(E*)d2).weight;}void makeSet(int n){ for(int i = 0; i <= n; i++) father[i] = i;}int fi 阅读全文
posted @ 2011-04-10 06:20 L.. 阅读(117) 评论(0) 推荐(0) 编辑
摘要: /*状态转移方程MAXLEN = max{MAXLEN(area[i-1][j]),MAXLEN(area[i+1][j],MAXLEN(area[i][j+1])),MANLEN(area[i][j-1]) | area[i][j] > ..} + 1 */#include"stdio.h"#include"string.h"int row,col,area[110][110];int f[110][110];int max,i,j;void in(){ scanf("%d%d",&row,&col); for 阅读全文
posted @ 2011-04-10 06:17 L.. 阅读(150) 评论(0) 推荐(0) 编辑
摘要: /*并查集!最后判断有几个父亲就是答案了*/#include <iostream>#include <set>using namespace std;struct G{ int left; int right; int up; int down;};const int MAXN = 50;int father[MAXN * MAXN]; int m,n;G g[11] = {{1,0,1,0},{0,1,1,0},{1,0,0,1},{0,1,0,1},{0,0,1,1},{1,1,0,0},{1,1,1,0},{1,0,1,1},{1,1,0,1},{0,1,1,1} 阅读全文
posted @ 2011-04-10 06:15 L.. 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 这种处理日期的方法很值得学习!很巧妙!#include <stdio.h>int year[2] = {365, 366}; //0 非润年int month[2][12] = {{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}}; //0 非润年的月份//2000年1月1日 Saturday char week[7][10]={"Saturday","Sunday","Monday","Tuesday" 阅读全文
posted @ 2011-04-10 06:01 L.. 阅读(199) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <string.h>char haabMonth[19][10] = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", 阅读全文
posted @ 2011-04-10 05:40 L.. 阅读(139) 评论(0) 推荐(1) 编辑
摘要: #include <iostream>#include <algorithm>#include <stack>#define L(x) ((x) << 1)#define R(x) ((x) << 1 | 1)using namespace std;const int MAXN = 50000;struct SegTree{ int l, r; int mval, lval, rval; int cover; //1 没坏 0 坏 -1 有的坏了 有的没坏 void init(int c){ lval = rval = mval = 阅读全文
posted @ 2011-04-10 05:37 L.. 阅读(377) 评论(0) 推荐(1) 编辑
摘要: /*先按l排序 再每次找出一段最长的递增序列!*/#include <stdio.h>#include <stdlib.h>#include <string.h>struct stick{ int l, w;}st[50010];bool used[50010];int cmp(const void *a, const void *b){ stick *s1 = (stick*)a, *s2 = (stick*)b; if(s1 -> l == s2 -> l) return s1 -> w - s2 -> w; return s1 阅读全文
posted @ 2011-04-09 03:13 L.. 阅读(148) 评论(0) 推荐(0) 编辑
摘要: /*抄书上的程序..用c语言写的老是WA每次选效益最高的交换*/#include <iostream>#include <fstream>#include <vector>#include <algorithm>using namespace std;struct Mouse{ double j,f; double shouyi;};bool comp(const Mouse &d1,const Mouse &d2){ if(d1.shouyi != d2.shouyi) return d2.shouyi < d1.shou 阅读全文
posted @ 2011-04-09 03:09 L.. 阅读(191) 评论(0) 推荐(0) 编辑
摘要: /*转化为数塔问题dp[i][j] i 表示第i秒 j表示第j个位置 能够拿到的最大馅饼数状态转移方程dp[i][j] = max{dp[i+1][j-1],dp[i+1][j],dp[i+1][j+1]} + a[i][j]; 时刻注意边界*/#include <stdio.h>#include <string.h>const int MAX = 100001; int dp[MAX][11]; //1 ~ 100000秒int max2(int d1,int d2){ return d1 > d2 ? d1 : d2;}int max3(int d1,int 阅读全文
posted @ 2011-04-09 02:59 L.. 阅读(229) 评论(0) 推荐(0) 编辑
摘要: /*经典的动态规划*/#include <iostream>using namespace std;char str1[1000];char str2[1000];int dp[1001][1001];int main(){ while(cin >> str1 >> str2){ int len1 = strlen(str1); int len2 = strlen(str2); int max = -1; memset(dp,0,sizeof(dp)); for(int i = 0; i < len1; i++){ for(int j = 0; j & 阅读全文
posted @ 2011-04-09 02:22 L.. 阅读(154) 评论(0) 推荐(0) 编辑