# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
93806 | 2019-01-11T13:22:43 Z | kjain_1810 | Shell (info1cup18_shell) | C++17 | 46 ms | 8568 KB |
#include <bits/stdc++.h> #define pb push_back #define f first #define s second #define ind(a) scanf("%d", &a) #define inlld(a) scanf("%lld", &a) #define ind2(a, b) scanf("%d%d", &a, &b) #define inlld2(a, b) scanf("%lld%lld", &a, &b) #define ind3(a, b, c) scanf("%d%d%d", &a, &b, &c) #define inlld3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c) using namespace std; const int N=1e3+5; const int MOD=1e9+7; typedef long long ll; typedef long double ld; ll n, m, p, arr[N], dp[N][N]; vector<ll>adj[N]; ll solve(ll i, ll j) { if(i==n) return j==p; if(dp[i][j]!=-1) return dp[i][j]; ll ret=0; for(ll a=0; a<adj[i].size(); a++) { ll v=adj[i][a]; if(v==arr[j+1]) ret=(ret+solve(v, j+1))%MOD; else ret=(ret+solve(v, j))%MOD; } return dp[i][j]=ret; } int main() { inlld3(n, m, p); for(ll a=1; a<=p; a++) { inlld(arr[a]); if(a!=p && arr[a]==n) { printf("0\n"); return 0; } } while(m--) { ll u, v; inlld2(u, v); adj[u].pb(v); } memset(dp, -1, sizeof(dp)); printf("%lld\n", solve(1, 0)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 8316 KB | Output is correct |
2 | Correct | 7 ms | 8184 KB | Output is correct |
3 | Correct | 7 ms | 8312 KB | Output is correct |
4 | Correct | 7 ms | 8184 KB | Output is correct |
5 | Correct | 19 ms | 8312 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 8316 KB | Output is correct |
2 | Correct | 7 ms | 8184 KB | Output is correct |
3 | Correct | 7 ms | 8312 KB | Output is correct |
4 | Correct | 7 ms | 8184 KB | Output is correct |
5 | Correct | 19 ms | 8312 KB | Output is correct |
6 | Correct | 7 ms | 8312 KB | Output is correct |
7 | Correct | 46 ms | 8568 KB | Output is correct |
8 | Incorrect | 10 ms | 8440 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 8312 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 8316 KB | Output is correct |
2 | Correct | 7 ms | 8184 KB | Output is correct |
3 | Correct | 7 ms | 8312 KB | Output is correct |
4 | Correct | 7 ms | 8184 KB | Output is correct |
5 | Correct | 19 ms | 8312 KB | Output is correct |
6 | Correct | 7 ms | 8312 KB | Output is correct |
7 | Correct | 46 ms | 8568 KB | Output is correct |
8 | Incorrect | 10 ms | 8440 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |