Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <set>
- using namespace std;
- int A[502][502], n, B[1003], mn;
- set <int> c;
- int main()
- {
- cin >> n;
- for(int i =0; i < n; i++)
- {
- mn = 100000;
- for(int j =0; j < n; j++)
- {
- cin >> A[i][j];
- if((i == j) && (A[i][j] != 0))
- {
- cout << -1;
- return 0;
- }
- if(i != j && A[i][j] < mn) mn = A[i][j];
- }
- B[i] = mn;
- }
- for(int i = 0; i < n; i++)
- for(int j = 0; j < n; j++)
- {
- if(A[i][j] != max(B[i], B[j]) && i != j)
- {
- cout << -1;
- return 0;
- }
- }
- for(int i =0; i < n; i++)
- cout << B[i] << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement