• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
Eric.cpp
博客园 | 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理

随笔分类 -  连通性

 
hdu-4324(拓扑排序&强连通)
摘要:结论题:竞赛图中有环,则必存在三元环。拓扑排序判环,没什么好说的了。附代码:View Code #include <iostream>#include <string.h>#include <stdio.h>using namespace std;#define E 2002char a[E][E];int map[E][E];int count[E];bool Topsort(int n,int edge[][E]){ int i,top=-1; for(i=0;i<n;i++) if(count[i]==0) { count[i... 阅读全文
posted @ 2012-08-01 18:38 Eric.cpp 阅读(291) 评论(0) 推荐(0)
2012东北地区赛C题(缩点+bfs)
摘要:数据出水了,直接bfs也能过。下面是我写的缩点+bfs的方法。View Code /*Source CodeProblem: 1003Username: 2010201211Run Time: 36MSMemory: 5188KLanguage:C++JudgeStatus: Accepted*/#include <iostream>#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;#define V 1005#define E 1005000 阅读全文
posted @ 2012-07-01 13:39 Eric.cpp 阅读(208) 评论(0) 推荐(0)
Codeforces Round #122 (Div. 1)-->TLE代码 跪求(n^2)的最小割顶集算法(Stoer-Wagner)
摘要:A. Cutting Figuretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou've gotten an n × m sheet of squared paper. Some of its squares are painted. Let's mark the set of all painted squares as A. Set A is connected. Your task is to find 阅读全文
posted @ 2012-06-04 10:04 Eric.cpp 阅读(543) 评论(0) 推荐(0)
拓扑排序
摘要:邻接矩阵:View Code #include <iostream>#include <stdio.h>using namespace std;#define E 1001void Topsort(int count[],int n,int edge[][E]){ int i,top=-1; for(i=0;i<n;i++) if(count[i]==0) { count[i]=top; top=i; } for(i=0;i<n;i++) if(top==-1) ... 阅读全文
posted @ 2012-05-25 15:40 Eric.cpp 阅读(363) 评论(0) 推荐(0)
【专题】图的连通性问题---有向图的强连通性的求解及应用
摘要:1.Tarjan算法:View Code #include <stdio.h>#include <iostream>#include <string.h>#define E 10000#define V 1000using namespace std;void tarjan(int u);void solve();void suodian();void addedge(int u,int v,int c);int top,cnt,index,n,ecnt;bool instack[V];int stack[V],id[V],dfn[V],low[V],num 阅读全文
posted @ 2012-05-25 12:46 Eric.cpp 阅读(1205) 评论(0) 推荐(0)
【专题】图的连通性问题---无向图的点连通性的求解及应用
摘要:1.求割点:(1).朴素的方法:n^3(2).Tarjan求割点:n^2顶点u是割点的充要条件:1.如果顶点u是深度优先搜索生成树的根,则u至少有两个子女.2.如果u不是生成树的根,则它至少有一个子女w,从w出发,不可能通过w、w的子孙,以及一条回边组成的路径到达u的祖先.(low[w]>=dfn[u]).去掉割点,将原来的连通图分成了几个连通分量?1.如果割点u是根结点,则有几个子女,就分成了几个连通分量.2.如果割点u不是根结点,则有d个子女w,使得low[w]>=dfn[u],则去掉该结点,分成了d+1个连通分量。下面是一段求割点的代码:View Code /*Source 阅读全文
posted @ 2012-05-23 22:31 Eric.cpp 阅读(2148) 评论(0) 推荐(0)
 

公告


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3