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...
        
阅读全文
 
        
            
    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
        
阅读全文
 
        
            
    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
        
阅读全文
 
        
            
    拓扑排序
    
            
摘要:邻接矩阵: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) ...
        
阅读全文
 
        
            
    【专题】图的连通性问题---有向图的强连通性的求解及应用
    
            
摘要: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
        
阅读全文
 
        
            
    【专题】图的连通性问题---无向图的点连通性的求解及应用
    
            
摘要: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 
        
阅读全文