Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- vector < vector < int >> land;
- int was[1010];
- void dfs(int vp) {
- was[vp] = 1;
- for (int i = 0; i < (int)land[vp].size(); i++) {
- if (was[land[vp][i]] == 0)
- dfs(land[vp][i]);
- }
- }
- int main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int N, M, V, U, K, a, b;
- cin >> N >> M >> V >> U;
- land.resize(N);
- for (int i = 0; i < M; i++) {
- cin >> a >> b;
- --a;
- --b;
- land[a].push_back(b);
- }
- cin >> K;
- int bylk;
- for (int i = 0; i < K; i++) {
- cin >> bylk;
- land[bylk - 1].clear();
- }
- dfs(V - 1);
- if (was[U - 1])
- cout << "YES";
- else cout << "NO";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement