10 条题解
-
-8
#include<bits/stdc++.h> using namespace std; int u,v,n,m,d[10001],b[10001],tot,ans; vector<int>a[10001]; queue<int>q; int main(){ cin>>n>>m; while(m--){ cin>>u>>v; a[v].push_back(u); ++d[u]; } for(int i = 1;i<=n;i++){ if(d[i]==0){ q.push(i); b[i]=100; } } while(!q.empty()){ ++tot; v=q.front(); q.pop(); ans+=b[v]; for(int i = 0;i<int(a[v].size());i++){ u=a[v][i]; b[a[v][i]]=max(b[v]+1,b[u]); if((--d[u])==0)q.push(u); } } if(tot<n) cout<<"Poor Xed"<<endl; else cout<<ans<<endl; return 0; }
信息
- ID
- 471
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 2
- 标签
- 递交数
- 359
- 已通过
- 99
- 上传者