Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     ifstream in("input.txt");
  6.     ofstream out("output.txt");
  7.     int n, m, x, y;
  8.     in >> n >> m;
  9.     short matrix[n][n];
  10.     for(int i = 0; i < n; i++){
  11.         for(int j = 0; j < n; j++){
  12.             matrix[i][j] = 0;
  13.         }
  14.     }
  15.     for(int i = 0; i < m; i++){
  16.         in >> x >> y;
  17.         if(matrix[x - 1][y - 1] == 1 || matrix[y - 1][x - 1] == 1){
  18.             out << "YES";
  19.             return 0;
  20.         }
  21.         matrix[x - 1][y - 1] = 1;
  22.     }
  23.     out << "NO";
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement