SHARE
TWEET

Untitled

a guest Feb 12th, 2020 28 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top