Guest User

Untitled

a guest
Feb 12th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4.     int adj[1000][1000];
  5.     for (int i=0; i<1000; i++){
  6.         for (int j=0; j<1000; j++){
  7.             adj[i][j] = 0;
  8.         }
  9.     }
  10.    
  11.     int A,B,M,N;
  12.     cin >> M >> N;
  13.     for (int i=0; i<M; i++){
  14.         cin >> A >> B;
  15.         adj[A][B] = 1;
  16.         adj[B][A] = 1;
  17.     }
  18.     int J;
  19.     cin >> J;
  20.     for (int i=0; i<J; i++){
  21.         cin >> A >> B;
  22.         if (adj[A][B] == 1){
  23.             cout << "YES" << endl;
  24.         }
  25.         else if(adj[A][B] == 0){
  26.             cout << "NO" << endl;
  27.         }
  28.     }
  29. }
Add Comment
Please, Sign In to add comment