Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- int adj[1000][1000];
- for (int i=0; i<1000; i++){
- for (int j=0; j<1000; j++){
- adj[i][j] = 0;
- }
- }
- int A,B,M,N;
- cin >> M >> N;
- for (int i=0; i<M; i++){
- cin >> A >> B;
- adj[A][B] = 1;
- adj[B][A] = 1;
- }
- int J;
- cin >> J;
- for (int i=0; i<J; i++){
- cin >> A >> B;
- if (adj[A][B] == 1){
- cout << "YES" << endl;
- }
- else if(adj[A][B] == 0){
- cout << "NO" << endl;
- }
- }
- }
Add Comment
Please, Sign In to add comment