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

2013年8月15日

摘要: 题意 就是给你一棵树,树边的长度为定值1,树的边长上面有权值,破坏一条边的费用就是他的权值; 求破坏一条边之后,分成两颗树A,B中直径最长的b 然后 乘上他边上的权值最小,求那条边的 id方法 不要多说,就是保留三个最优值放在节点;两次 DFS 对树的 正向边 反方向边 赋值;最后一次性求出结果;#pragma comment(linker, "/STACK:10240000000000,10240000000000")#include#include#include#include#includeusing namespace std;#define maxn 22234 阅读全文
posted @ 2013-08-15 20:23 浪舟 阅读(335) 评论(0) 推荐(0) 编辑

2013年5月19日

摘要: 链接 http://acm.hdu.edu.cn/showproblem.php?pid=2196#include<iostream>#include<stdio.h>#include<cstring>#include<algorithm>using namespace std;struct date{ long long len,Max,v,next;}edge[111234];long long head[111234],total,dp[111234];bool vis[111234];inline long long max( long 阅读全文
posted @ 2013-05-19 16:45 浪舟 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 链接 http://icpc.njust.edu.cn/Contest/194/Problem/C#include<iostream>#include<stdio.h>#include<algorithm>#include<cstring>#include<cmath>using namespace std;long long pow( int num ){ long long res = 1; for( int i = 1; i <= num; i++ ) res *= 2; return res;}long long max 阅读全文
posted @ 2013-05-19 14:00 浪舟 阅读(259) 评论(0) 推荐(0) 编辑

2013年5月18日

摘要: 链接http://acm.hdu.edu.cn/status.php#include<iostream>#include<stdio.h>#include<cstring>#include<algorithm>#define max( a,b ) ( (a)>(b)?(a):(b) )using namespace std;struct date{ int v,next;}edge[2000000];int N,total,head[6004],dp[6004][2];bool vis[6004];void add_edge( int u, 阅读全文
posted @ 2013-05-18 14:51 浪舟 阅读(154) 评论(0) 推荐(0) 编辑

2013年5月16日

摘要: lcs 最长公共子序列 O(nlogn)算法2012-08-19 21:51:27--点击数:173 更多 0最长公共子序列问题:给定2个字符串,求其最长公共子串。如abcde和dbada的最长公共字串为bd。动态规划:dp[i][j]表示A串前i个和B串前j个的最长公共子串的长度。则若A[i] == B[j] , dp[i][j] = dp[i-1][j-1] + 1;否则 dp[i][j] = max(dp[i-1][j],dp[i][j-1]);时间复杂度O(N*M)。dp[i][j]仅在A[i]==B[j]处才增加,对于不相等的地方对最终值是没有影响的。故枚举相等点处可以对其进行优化。 阅读全文
posted @ 2013-05-16 22:04 浪舟 阅读(422) 评论(0) 推荐(0) 编辑

2013年5月15日

摘要: 链接 http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1459#include<iostream>#include<stdio.h>#include<cstring>#include<algorithm>#include<vector>using namespace std;struct date{ int v,next;}edge[212345];int k,head[112345];vector<int>v;bool vis[112345],vic[112345],vi 阅读全文
posted @ 2013-05-15 11:55 浪舟 阅读(224) 评论(0) 推荐(0) 编辑

2013年5月14日

摘要: 链接http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1466#include<iostream>#include<stdio.h>#include<algorithm>#include<cstring>#include<vector>using namespace std;inline int max( int a,int b ){return (a)>(b)?(a):(b);}struct date{ int pre,pos;}temp;struct date2{ int v, 阅读全文
posted @ 2013-05-14 22:05 浪舟 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 链接http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1437#include<iostream>#include<algorithm>#include<stdio.h>#include<cstring>#include<cmath>using namespace std;const double PI = acos(-1.0);const double EPS = 1e-10;struct date{ double x,y;}lt,rt,ml,mr;inline double max( 阅读全文
posted @ 2013-05-14 16:29 浪舟 阅读(302) 评论(0) 推荐(0) 编辑
摘要: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1465#include<iostream>#include<stdio.h>#include<cstring>#include<algorithm>using namespace std;double arr[112345];int N;inline double Abs( double x ){ return x>0?x:-x;}inline double Min( double a,double b ){return a>b?b:a 阅读全文
posted @ 2013-05-14 14:19 浪舟 阅读(221) 评论(0) 推荐(0) 编辑

2013年5月13日

摘要: 我没想到 暴力 可以过 真是一个水啊http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5013#include<iostream>#include<stdio.h>#include<cstring>#include<algorithm>using namespace std;int vis[110][110];int main( ){ int T,N,M,K,u,v; scanf("%d",&T); while( T-- ) { scanf(" 阅读全文
posted @ 2013-05-13 16:46 浪舟 阅读(320) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 11 下一页

导航