【Luogu】 P1726 上白泽慧音
来源:互联网 发布:广数980g76编程实例 编辑:程序博客网 时间:2024/06/05 17:48
这个题目名……感觉……很……
很裸的一个tarjan吧……
不说了,上代码(代码是谁)
#include <bits/stdc++.h>using namespace std;vector <int> que[51000];int tim,ans,stc[51000],ps,out[51000],flag,dfn[51000],low[51000],clr[51000],ins[51000],top,color_num,count=0,maxn,rem,an[51000];void tarjan(int x){ tim++; dfn[x]=tim; low[x]=tim; ins[x]=1; stc[++top]=x; for(int i=0;i<que[x].size();i++) { int tmp=que[x][i]; if(dfn[tmp]==0) { tarjan(tmp); low[x]=min(low[x],low[tmp]); } else if(ins[tmp]) low[x]=min(low[x],low[tmp]); } if(dfn[x]==low[x]) { if(stc[top]==x) ps++; flag=1; ins[x]=0; clr[x]=++color_num; while(stc[top]!=x) { flag++; clr[stc[top]]=color_num; ins[stc[top]]=0; top--; } if(flag>maxn) maxn=flag,rem=color_num; top--; }}int main(){ int n,m; cin>>n>>m; for(int i=1;i<=m;i++) { int x,y,t; cin>>x>>y>>t; if(t==1) { que[x].push_back(y); } else { que[x].push_back(y); que[y].push_back(x); } } for(int i=1;i<=n;i++) if(!dfn[i]) tarjan(i); cout<<maxn<<endl; for(int i=1;i<=n;i++) if(clr[i]==rem) printf("%d ",i); return 0;}
其实写的过程中没出什么错,就是……“tm”居然是关键字……
0 0
- 【Luogu】 P1726 上白泽慧音
- [P1726]上白泽慧音
- P1726 上白泽慧音
- 洛谷 P1726 上白泽慧音
- 洛谷 P1726 上白泽慧音
- 洛谷 P1726 上白泽慧音
- C++ P1726 上白泽慧音
- 洛谷 P1726 上白泽慧音
- 洛谷P1726 上白泽慧音(强连通分量)
- Luogu 1197
- 【Luogu】 食物链
- lUOGU P1540
- luogu 1313
- luogu 1082
- luogu 1024
- luogu 1044
- luogu 1072
- luogu 1063
- 程序的调用机制及目标文件有什么
- ubuntu14.04上使用glfw
- CPUFreq驱动随笔(一)
- 页面置换算法及磁盘调度算法
- yii2.0目录结构
- 【Luogu】 P1726 上白泽慧音
- 零基础学习wince开发-环境搭建
- A1014. Waiting in Line (30)
- HTTP协议详解
- 数据库范式那些事
- C++设计模式:职责链模式<初探>
- 圆弧的动画效果实现
- The POM for xxxx is missing, no dependency information available
- Java 获取耗时中文描述