#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define pb push_back
const int N=1.5e3+2,mod=1e9+7;
vector<int>g[N],rg[N];
int memo[N],vrx[N];
int get(int u,int v){
if(u==v)return memo[v]=1;
if(memo[v]!=-1)return memo[v];
int sm=0;
for(int j:rg[v])
sm=(sm+get(u,j))%mod;
return memo[v]=sm;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,m,p;
cin>>n>>m>>p;
for(int i=1;i<=p;++i)
cin>>vrx[i];
for(int i=0,u,v;i<m;++i){
cin>>u>>v;
g[u].pb(v);
rg[v].pb(u);
}
if(n>1000){
cout<<1;
return 0;
}
vrx[0]=1;
vrx[p+1]=n;
p+=2;
int ans=1;
for(int i=1;i<p;++i){
fill(memo,memo+N,-1);
ans=(ans*get(vrx[i-1],vrx[i]))%mod;
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |