Submission #1080549

#TimeUsernameProblemLanguageResultExecution timeMemory
1080549batsukh2006Shell (info1cup18_shell)C++17
100 / 100
216 ms76512 KiB
#include<iostream> #include<stdio.h> #include<math.h> #include<map> #include<string> #include<algorithm> #include<vector> #include<string.h> #include<utility> #include<set> #include<cmath> #include<queue> #include<deque> #include<functional> #include<stack> #include<limits.h> #include<iomanip> #include<unordered_map> using namespace std; #define MOD 1000000007 #define int long long #define ss second #define ff first #define endl '\n' int n,m,p; const int mxN=1e6+1; vector<bool> vis(mxN); vector<int> v[mxN],c(mxN),cnt(mxN),ans(mxN); void dfs(int a){ vis[a]=1; if(a==n){ cnt[a]=1; ans[a]=1; }else{ for(auto node: v[a]){ if(!vis[node]) dfs(node); if(cnt[node]>cnt[a]){ cnt[a]=cnt[node]; ans[a]=ans[node]; }else if(cnt[node]==cnt[a]){ ans[a]=(ans[a]+ans[node])%MOD; } } } if(a==c[p-cnt[a]+1]) cnt[a]++; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m>>p; for(int i=1; i<=p; i++) cin>>c[i]; for(int i=1; i<=m; i++){ int a,b; cin>>a>>b; v[a].push_back(b); } dfs(1); cout<<ans[1]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...