Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5.  
  6. using namespace std;
  7. static const int N = 10;
  8. int main(int argc, char **argv)
  9.  
  10.  
  11. {
  12.     int i,p,q,id[N];
  13.     for(i = 0;i < N;i++)id[i] = i;
  14.    
  15.     int kk = 0; //mosti
  16.     int jj = 0; //ostrova
  17.     int n1,n2, hh;
  18.     cin >> hh >> kk >> n1 >> n2;
  19.     for(int i = 0; i<kk;i++){
  20.         cin >> p >> q;
  21.         for(int g = 0 ; g < N;g++){
  22.             if(id[g] == id[p]) id[g] = id[q];
  23.         }
  24.     }
  25.    
  26.     cin >> jj;
  27.     for(int i = 0; i < jj;i++){
  28.         int h;
  29.         cin >>h;
  30.         for(int j = 0;j < N;j++)
  31.             if(j ==h)id[j] = -1000;
  32.        
  33.    
  34.     }
  35.  
  36.     if(id[n1] == id[n2] && id[n1] >=0)
  37.         cout << "yes" << endl;
  38.     else{
  39.         cout << "no" << endl;
  40.     }  
  41.    
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement