Submission #1134206

#TimeUsernameProblemLanguageResultExecution timeMemory
1134206bpptidpShell (info1cup18_shell)C++20
10 / 100
382 ms11096 KiB
#include<bits/stdc++.h> using namespace std; #define int int64_t #define pb push_back const int N=1e3+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+=get(u,j); 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); } 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...