minimario

Is it a Tree?: e-olymp

Jun 19th, 2015
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int x;
  6.     cin >> x;
  7.     int tot = 0;
  8.     for (int i=0; i < x*x; i++) {
  9.         int y;
  10.         cin >> y;
  11.         if (y == 1) {
  12.             tot += 1;
  13.         }
  14.     }
  15.  
  16.     if (tot == 2*(x-1) {
  17.         cout << "YES" << endl;
  18.     }
  19.    
  20.     else {
  21.         cout << "NO" << endl;
  22.     }
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment