Submission #691001

#TimeUsernameProblemLanguageResultExecution timeMemory
691001divadShell (info1cup18_shell)C++14
100 / 100
230 ms48496 KiB
#include <bits/stdc++.h> #define MOD 1000000007 #define MAX 1000002 using namespace std; int n,m,p,x,y,dp[MAX],cnt[MAX],mrc[MAX]; /// dp[nod] = in ce nod trebuie sa merg /// cnt[nod] = cate drumuri sunt vector<int> v[MAX]; void dfs(int nod){ if(nod == n){ dp[nod] = 1; cnt[nod] = 1; if(nod == mrc[p-dp[nod]+1]){ dp[nod]++; } }else{ for(int vecin: v[nod]){ if(dp[vecin] == 0){ dfs(vecin); } if(dp[vecin] > dp[nod]){ dp[nod] = dp[vecin]; cnt[nod] = cnt[vecin]; }else if(dp[vecin] == dp[nod]){ cnt[nod] += cnt[vecin]; } cnt[nod] %= MOD; } if(nod == mrc[p-dp[nod]+1]){ dp[nod]++; } } } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m >> p; for(int i = 1; i <= p; i++){ cin >> mrc[i]; } for(int i = 1; i <= m; i++){ cin >> x >> y; v[x].push_back(y); } dfs(1); cout << cnt[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...