Advertisement
NHumme

A

Apr 26th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <set>
  4. using namespace std;
  5. int A[502][502], n, B[1003], mn;
  6. set <int> c;
  7. int main()
  8. {
  9.     cin >> n;
  10.     for(int i =0; i < n; i++)
  11.     {
  12.         mn = 100000;
  13.         for(int j =0; j < n; j++)
  14.         {
  15.             cin >> A[i][j];
  16.             if((i == j) && (A[i][j] != 0))
  17.             {
  18.                 cout << -1;
  19.                 return 0;
  20.             }
  21.             if(i != j && A[i][j] < mn) mn = A[i][j];
  22.         }
  23.         B[i] = mn;
  24.     }
  25.     for(int i = 0; i < n; i++)
  26.         for(int j = 0; j < n; j++)
  27.     {
  28.         if(A[i][j] != max(B[i], B[j]) && i != j)
  29.         {
  30.             cout << -1;
  31.             return 0;
  32.         }
  33.     }
  34.  
  35.     for(int i =0; i < n; i++)
  36.         cout << B[i] << " ";
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement