-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPP0260.cpp
More file actions
48 lines (45 loc) · 1.11 KB
/
CPP0260.cpp
File metadata and controls
48 lines (45 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <bits/stdc++.h>
using namespace std;
#define fastsync() \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define ll long long
const int MOD = 1e9 + 7;
const int MAX = 1e6 + 7;
void run_case() {
int n;
cin >> n;
int M[1000];
for (int i = 0; i < n * n; i++) {
cin >> M[i];
}
sort(M, M + n * n);
int N[100][100];
int t = n, g = 0;
for (int i = 1; i <= n / 2 + 1; i++) {
for (int j = i; j <= t; j++)
N[i][j] = M[g++];
for (int j = i + 1; j <= t; j++)
N[j][t] = M[g++];
for (int j = t - 1; j >= i; j--)
N[t][j] = M[g++];
for (int j = t - 1; j > i; j--)
N[j][i] = M[g++];
t--;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++)
cout << N[i][j] << " ";
cout << endl;
}
}
int main() {
fastsync();
int Test = 1;
// cin >> Test;
for (int test = 1; test <= Test; ++test) {
run_case();
}
return 0;
}