设为首页 加入收藏

TOP

hihoCoder_#1067_最近公共祖先·二(LCA模板)(二)
2015-11-21 00:56:25 来源: 作者: 【 】 浏览:4
Tags:hihoCoder_#1067_ 最近 公共 祖先 · LCA 模板
的LCA问题。

?

代码清单:

?

#include
#include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int maxn = 1e5 + 5; struct Edge{ int v,id; Edge(int v,int id){ this -> v = v; this -> id = id; } }; int n,m,id,root; string name1,name2; bool hasfa[maxn]; map idx; string str[maxn]; vector graph[maxn]; int father[maxn]; int color[maxn],ans[maxn]; vector edge[maxn]; int Find(int x){return x!=father[x] ? father[x]=Find(father[x]) : father[x]; } void init(){ for(int i=0;i >name1>>name2; int idx1=get_idx(name1); int idx2=get_idx(name2); graph[idx1].push_back(idx2); hasfa[idx2]=true; } scanf(%d,&m); for(int i=1;i<=m;i++){ cin>>name1>>name2; int idx1=get_idx(name1); int idx2=get_idx(name2); edge[idx1].push_back(Edge(idx2,i)); edge[idx2].push_back(Edge(idx1,i)); } } void tarjan(int u){ color[u]=1; for(int i=0;i

?


?

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇uvalive 4986(三分查找) 下一篇C++对象模型――成员初始化列表(..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: