#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
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];
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
63068 KB |
Output is correct |
2 |
Incorrect |
16 ms |
63068 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
63068 KB |
Output is correct |
2 |
Incorrect |
16 ms |
63068 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1012 ms |
63324 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
63068 KB |
Output is correct |
2 |
Incorrect |
16 ms |
63068 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |