#include #include #include #include #include #include #include #define maxn 1010 #define inf (1<<30) using namespace std; ifstream fin("A.in"); ofstream fout("A.out"); int n,t,a[maxn*maxn],b[maxn][maxn]; bool cmp (int a, int b) { return a > b; } int main () { cin >> n; for (int i =1 ; i <= n; ++i) { for (int j = 1; j <= n; ++j) { ++t; cin >> a[t]; } } sort (a+1, a+t+1, cmp); t = 0; for (int i = 1; i <= n; ++i) { ++t; b[i][i] = a[t]; } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { if (i != j) { ++t; b[i][j] = a[t]; } } } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { cout << b[i][j] << " "; } cout << "\n"; } }