# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
862188 |
2023-10-17T16:25:27 Z |
Raul_A |
Shell (info1cup18_shell) |
C++14 |
|
1000 ms |
63324 KB |
#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];
| ^~~
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1012 ms |
63324 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |