-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcp4.cpp
More file actions
47 lines (38 loc) · 801 Bytes
/
cp4.cpp
File metadata and controls
47 lines (38 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <vector>
using namespace std;
int V, E;
int s, m, e;
bool chk[10001][10001];
vector<int> ver[10001];
int D[10001][10001];
int _find(int stt, int fin)
{
//cout<<stt<<' '<<fin<<"\n";
if(stt == fin) return 1;
if(D[stt][fin]) return D[stt][fin];
int tnum = (int)ver[fin].size();
for(int i=0; i<tnum; i++)
{
D[stt][fin] = (D[stt][fin] + _find(stt, ver[fin][i]))%10007;
}
return D[stt][fin];
}
int main(void)
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>V>>E;
cin>>s>>m>>e;
int stt, fin;
for(int i=0; i<E; i++)
{
cin>>stt>>fin;
chk[stt][fin] = 1;
ver[fin].push_back(stt);
}
//_find(s, m);
cout<<(_find(s, m)*_find(m, e))%10007<<"\n";
return 0;
}