摘要: 找有这个题目的oj找的好辛苦算法详见黑书119页动态规划#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<algorithm>using namespace std;struct toy{ int x; int y; int z;}p[110];//1代表x和y在上//2代表x和z在上//3代表y和z在上int d[110][110][110][4];int n,m;//编号为1,2,,,,n//d[i][a][b][k]表示已经 阅读全文
posted @ 2012-08-03 21:31 willzhang 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #include<math.h> 5 #include<algorithm> 6 using namespace std; 7 #define left 2 8 #define right 4 9 #define up 110 #define down 311 int n;12 int a[1000];13 int effort(int a,int b)14 {15 if(a==0)16 {17 return 阅读全文
posted @ 2012-08-03 14:24 willzhang 阅读(123) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<algorithm>using namespace std;int linjie[110][110];int ans[110];int n;int t[110];int meet[110][110];//-1表示未初始化,0表示不能相遇,1表示能相遇void found(int l,int r){ int i; meet[l][r]=0; if(l==r-1) { meet[l][ 阅读全文
posted @ 2012-08-03 09:56 willzhang 阅读(158) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<algorithm>using namespace std;int n;int map[8][8];long double ans[20][10][10][10][10];//存储已经计算出的结果long double cs[8][8];//预处理算出[0][0]到[i][j]的棋盘的分数总和的平方#define in(x,y) x>=0&&x<8&am 阅读全文
posted @ 2012-08-02 22:37 willzhang 阅读(425) 评论(0) 推荐(0) 编辑
摘要: 黑书上的第一种优化#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<algorithm>char map[120];struct T{ char str[220]; int len;//字符串的长度 int num;//所加字符的数目}res[120][120];bool flag[120][120];void digui(int l,int r){ char temp; int i; if(l==r) { if(map[l]== 阅读全文
posted @ 2012-08-01 20:05 willzhang 阅读(245) 评论(0) 推荐(0) 编辑
摘要: //356K 0MS第一道网络流的题,注意重边#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<algorithm>#include<queue>using namespace std;int linjie[220][220];bool visit[220];int pre[220];//找这个节点之前的节点int N,M;queue<int>Q;void dayin(){ int i,j; for(i=1 阅读全文
posted @ 2012-07-28 21:20 willzhang 阅读(129) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<algorithm>using namespace std;#define pi acos(-1.0)struct point{ double x; double y;}pp[1010];struct Vector{ double x; double y;};double chaji(Vector a,Vector b)//a*b{ return a.x*b.y-b.x*a.y;} 阅读全文
posted @ 2012-07-28 16:37 willzhang 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 捣鼓了一整天,随机了100个样例全过还是WA,后来发现最大值设小了。。。T T#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<algorithm>#include<queue>using namespace std;#define MAX 99999999999999struct point{ double x; double y;};struct line{ point first;//西南 point last; 阅读全文
posted @ 2012-07-28 10:31 willzhang 阅读(170) 评论(0) 推荐(0) 编辑
摘要: //264K 32MS#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<algorithm>#include<stack>using namespace std;stack<int>S;struct node{ int id; node *next;}head[110];int n;int ranse;int index;int color[110];//每个节点的颜色bool visit[110];boo 阅读全文
posted @ 2012-07-26 22:21 willzhang 阅读(116) 评论(0) 推荐(0) 编辑
摘要: //1824K 250MS#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<algorithm>#include<stack>using namespace std;stack<int>S;int n,m;int num[10005];int ranse;struct node{ node *next; int id;}head[10005];//数组下标代表id,每条链表代表该点能到达的所有点int re 阅读全文
posted @ 2012-07-26 20:57 willzhang 阅读(123) 评论(0) 推荐(0) 编辑