记录编号 |
542332 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[WZOI 2011 S3] 消息传递 |
最终得分 |
100 |
用户昵称 |
leon |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.796 s |
提交时间 |
2019-09-23 19:10:47 |
内存使用 |
22.05 MiB |
显示代码纯文本
- #include<bits/stdc++.h>
- using namespace std;
- const int maxn=200005;
- int top,cnt,qwq;
- int sum[maxn],vis[maxn],sta[maxn],head[maxn],tot,dfn[maxn],low[maxn],tmp,belong[maxn];
- struct _{int to,next;}a[maxn*2];
- void add(int x,int y){
- a[++tot].to=y;
- a[tot].next=head[x];
- head[x]=tot;}
- void tarjan(int x){
- sta[++top]=x;
- vis[x]=1;
- dfn[x]=low[x]=++cnt;
- for(int i=head[x];i;i=a[i].next){
- if(dfn[a[i].to]==0){
- tarjan(a[i].to);
- low[x]=min(low[x],low[a[i].to]);}
- else if(vis[a[i].to]==1)low[x]=min(low[x],dfn[a[i].to]);}
- if(dfn[x]==low[x]){
- qwq++;
- do{
- belong[sta[top]]=qwq;
- sum[qwq]++;
- vis[sta[top]]=0;}
- while(sta[top--]!=x);
- }}
- int main(){
- freopen("messagew.in","r",stdin);
- freopen("messagew.out","w",stdout);
- int n,m,q,w;
- cin>>n>>m;//n_dian m_bian
- for(int i=1;i<=m;i++){
- cin>>q>>w;
- add(q,w);}
- for(int i=1;i<=n;i++){
- if(dfn[i]==0)
- tarjan(i);}
- for(int i=1;i<=n;i++){
- if(sum[belong[i]]>=2)cout<<'T';
- else cout<<'F';
- }
- return 0;
- }