雕刻时光

just do it……nothing impossible
随笔 - 547, 文章 - 0, 评论 - 82, 阅读 - 86万
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

随笔分类 -  一般图论题

摘要:http://poj.org/problem?id=3272由于数据顶点5000,边50000所以用静态链表出度为0有多个,入度为0的点有一个用f[i]表示i到出度为0的点 的边 有几条g[j]表示j到入度为0的点 的边 有几条两次dfs一条边的起点qi,终点end结果Max=max(f[qi]*g[end])注意点:重边有效View Code #include<stdio.h>#include<iostream>#include<string.h>using namespace std;const int N=5009;struct data{ int x 阅读全文

posted @ 2011-12-01 22:02 huhuuu 阅读(310) 评论(2) 推荐(0) 编辑

摘要:哈密顿回路判断是个NP问题,只有爆搜才可以N=64,显然直接爆搜不行AAAA……其实可以缩成一个点ACACAC……缩成两个点(如单独存在A,C就需要两个AC)ACGACGACG……缩成三个点(如单独存在A,C,G就需要三个ACG)再DFS即可View Code #include<stdio.h>#include<string.h>int add[10];int ok=0;int all=0;int from;void fun(char ss[10]){ int i; int t=0; for(i=0;ss[i];i++) { if(ss[i]=='A') 阅读全文

posted @ 2011-08-29 14:22 huhuuu 阅读(2874) 评论(0) 推荐(1) 编辑

摘要:View Code ABEDFCHGCBADEFGHif n<=0 return; int p=先序中的字母在中序中的位置。 Build(p,(char *)pre+1,(char *)mid); //递归构造左子树的遍历 Build(n-1-p,pre+p+1,mid+p+1); //递归构造右子树的遍历#include <stdio.h>#include <string.h>#define MAXN 1000char mid[MAXN],pre[MAXN],ans[MAXN];void Build(int n,char *pre,char *mid,char 阅读全文

posted @ 2011-03-10 14:25 huhuuu 阅读(216) 评论(0) 推荐(0) 编辑

摘要:空树也是树,森林不是树……还有注意ca++,大囧……View Code #include<stdio.h>int f[109];int jin[109];int find(int pos){ if(f[pos]==-1)return pos; return f[pos]=find(f[pos]);}int un(int a,int b){ int fa=find(a),fb=find(b); if(fa==fb)return 0; f[fa]=fb;return 1;}int main(){ int i,j,ca=0; while(1) { ca++; for(i=1;i<= 阅读全文

posted @ 2011-02-22 22:21 huhuuu 阅读(186) 评论(0) 推荐(0) 编辑

摘要:贪心的方法:每次将顶点度数排序,依次将度较大的点的度数减一;再排序再减……直到某点的度小于0时说明无解输出,或者所有点的度数都为零输出View Code 阅读全文

posted @ 2011-02-20 14:32 huhuuu 阅读(195) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示