Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <set>
- using namespace std;
- int n, m, v, u ,k;
- vector<pair<int,int>> raspopov_loh_kek_cheburek;
- vector<vector<int>> graf;
- set<int> bin;
- vector<int> gleb_kakaha_azazazaza;
- void dfs(int v, int par){
- gleb_kakaha_azazazaza[v] = 1;
- for (int u: graf[v]){
- if (!gleb_kakaha_azazazaza[u]){
- dfs(u,v);
- }
- }
- }
- int main(){
- cin >> n >> m >> v >> u;
- for (int i = 0; i < m; ++i){
- int left, right;
- cin >> left >> right;
- left--;
- right--;
- raspopov_loh_kek_cheburek.push_back({left, right});
- }
- cin >> k;
- for (int i = 0; i < k; ++i){
- int tmp;
- cin >> tmp;
- bin.insert(tmp - 1);
- }
- for (int i = 0; i < raspopov_loh_kek_cheburek.size(); ++i){
- if (bin.count(raspopov_loh_kek_cheburek[i].first) || bin.count(raspopov_loh_kek_cheburek[i].second)){
- raspopov_loh_kek_cheburek[i] = {-1,-1};
- }
- }
- graf.resize(n);
- for (auto elem: raspopov_loh_kek_cheburek){
- if (elem.first != -1){
- int a = elem.first;
- int b = elem.second;
- graf[a].push_back(b);
- graf[b].push_back(a);
- }
- }
- gleb_kakaha_azazazaza.resize(n);
- dfs(v - 1, 0);
- if (gleb_kakaha_azazazaza[u - 1]){
- cout << "YES";
- }
- else{
- cout << "NO";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement