https://www.luogu.org/recordnew/show/17756387
by 随便5057 @ 2019-03-31 00:39:53
@[随便5057](/space/show?uid=116835) 请问您的AC代呢?
by DARKSTALKING @ 2019-03-31 07:35:52
@[DARKSTALKING](/space/show?uid=121589) 网址
by 随便5057 @ 2019-04-01 12:30:47
@[随便5057](/space/show?uid=116835) 您没有开代码公开,我们其它人是看不到的
by DARKSTALKING @ 2019-04-01 20:37:19
#include<bits/stdc++.h>
using namespace std;
struct haha{
int to,next;
}node[50001];
bool vis[10001];
int t1,t2,t3,n,m;
int dnf[10001];
int low[10001];
int head[10001];
int q[10001];
int du[10001];
int sum[10001];
stack<int>s;
void add(int a,int b)
{
t1++;
node[t1].to=b;
node[t1].next=head[a];
head[a]=t1;
}
void tarjan(int x)
{
int k;
t2++;
dnf[x]=low[x]=t2;
vis[x]=1;
s.push(x);
for(int i=head[x];i;i=node[i].next)
{
k=node[i].to;
if(!dnf[k])
{
tarjan(k);
low[x]=min(low[x],low[k]);
}
else if(vis[k])
low[x]=min(low[x],dnf[k]);
}
if(low[x]==dnf[x])
{
t3++;
do
{
k=s.top();
q[k]=t3;
s.pop();
sum[t3]++;
}
while(x!=k);
}
}
int main()
{
cin>>n>>m;
int x,y;
for(int i=1;i<=m;i++)
{
cin>>x>>y;
add(x,y);
}
for(int i=1;i<=n;i++)
if(!dnf[i])
tarjan(i);
for(int i=1;i<=n;i++)
for(int j=head[i];j;j=node[j].next)
{
if(q[node[j].to]!=q[i])
du[q[i]]++;
}
bool b=0;
for(int i=1;i<=t3;i++)
if(!du[i])
{
if(!b)
b=i;
else
{
b=0;
break;
}
}
cout<<sum[b];
return 0;
}
by 随便5057 @ 2019-04-01 22:33:16
@[DARKSTALKING](/space/show?uid=121589) 已设置公开
说实话我觉得这题评测有问题吧。
代码不止一个bug都过了
vis忘了变false
把bool类型当整型赋值
by 随便5057 @ 2019-04-01 22:38:15
@[随便5057](/space/show?uid=116835) 我看看
by DARKSTALKING @ 2019-04-02 06:26:17
可恶
by SammyChu @ 2019-05-22 22:36:43