This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAX=1e6;
const int mod=1e9+7;
int n,m,k,target;
ll ans=1,dp[MAX+5];
vector<int> v;
unordered_map<int,int> G[MAX+5];
void read()
{
cin>>n>>m>>k;
v.resize(k);
for(auto& x: v) cin>>x;
for(int i=1,x,y;i<=m;i++)
{
cin>>x>>y;
G[x][y]++;
}
}
void dfs(int node,int father)
{
if(node==target) return;
for(auto x: G[node])
if(x.first!=father)
{
dfs(x.first,father);
int val=G[node][x.first];
dp[x.first]+=G[node][x.first];
dp[x.first]%=mod;
int arr=dp[node];
}
}
void solve()
{
int last=1;
for(int i=0;i<k;i++)
{
memset(dp,0,sizeof(dp));
target=v[i];
dfs(last,0);
ans=ans*dp[v[i]]%mod;
last=v[i];
}
cout<<ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
read();
solve();
return 0;
}
Compilation message (stderr)
shell.cpp: In function 'void dfs(int, int)':
shell.cpp:35:17: warning: unused variable 'val' [-Wunused-variable]
35 | int val=G[node][x.first];
| ^~~
shell.cpp:38:17: warning: unused variable 'arr' [-Wunused-variable]
38 | int arr=dp[node];
| ^~~
# | 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... |