模板:强连通分量&2-sat
2016-07-01 20:24
197 查看
void Tarjan(int x){ low[x]=ID[x]=++tot; st[++top]=x;Inst[x]=true; for(int i=fir[x];i;i=nxt[i]) if(!ID[to[i]]){ Tarjan(to[i]); low[x]=min(low[x],low[to[i]]); } else if(Inst[to[i]]) low[x]=min(low[x],ID[to[i]]); if(low[x]==ID[x]){ ++scnt; while(true){ int y=st[top--]; scc[y]=scnt; Inst[y]=false; if(x==y)break; } } } bool Check(){ for(int i=0;i<n*2;i++) if(!ID[i])Tarjan(i); for(int i=0;i<n;i++) if(scc[i*2]==scc[i*2+1]) return false; return true; }
http://blog.csdn.net/qq_24451605/article/details/47126143
相关文章推荐
- ACL理论
- lua计算 字符串宽度(中文英文混合)
- linux 客户端 Socket 非阻塞connect编程
- 查看centos版本方法
- hdu1576(A/B)扩展欧几里得
- 游苹果山赋——东南子(2010年旧文)
- javascript 插入节点appendChild()
- 长文干货!走近人脸检测:从?VJ?到深度学习(上)
- Android 的线程(AsyncTask、HandlerThread、IntentService详解)和线程池
- Android手势锁 连线时 产生多段连线的原因以及解决办法
- [其他]计算机网络-自顶向下方法 学习笔记
- 软件测试过程中应注意的风险
- 构造函数new执行与直接执行的区别
- hrbust 1131 波动序列【水题】
- 最短路径算法
- QT常用控件样式设计
- 程序员, 不要过度封装
- MIT算法导论笔记第一课
- ArcGIS制作花式边框视频教程
- android 隐藏软键盘代码