求大佬查错
查看原帖
求大佬查错
206834
_Herobrine_楼主2020/10/7 22:29

个人感觉代码没问题,可是连样例也过不了,mxqjQAQ

#include<bits/stdc++.h>
#define inf 0x7fffffff
#define ll long long
#define ull unsigned long long
#define exit exit(0)
#define re register int
#define endl '\n'
#define orz 80112002
using namespace std;
bool G[5001][5001];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int n,m,cnti[5001]={},cnto[5001]={},ans,dp[5001]={},h,x,y;queue<int>q;
	cin>>n>>m;
	for(int i=1;i<=m;i++) cin>>x>>y,G[x][y]=true,++cnti[y],++cnto[x];
	for(int i=1;i<=n;i++) if(!cnti[i]) q.push(i),dp[i]=1;
	while(!q.empty())
	{
		h=q.front(),q.pop();
		for(int i=1;i<=n;i++)
		{
			if(G[i][h])
			{
				dp[i]=(dp[i]+dp[h])%orz;
				if(!--cnti[i])
				{
					if(!cnto[i]) ans=(ans+dp[i])%orz;
					q.push(i);
				}
			}
		}
	}
	cout<<ans;
	return 0;
}
2020/10/7 22:29
加载中...