-
Notifications
You must be signed in to change notification settings - Fork 4
/
sah.cpp
42 lines (37 loc) · 790 Bytes
/
sah.cpp
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
#include <cstdio>
#include <string>
#include <vector>
using namespace std;
vector<vector<unsigned>> InitTable(size_t n) {
vector<vector<unsigned>> t(n);
for(size_t i = 0; i < n; ++i)
t[i].resize(n);
return t;
}
int main() {
freopen("sah.in","r",stdin);
size_t n;
scanf("%d",&n);
vector<vector<unsigned>> table = InitTable(n);
for(size_t i = 0; i < n; ++i)
table[0][i] = table[1][i] = 1;
unsigned zone = 2;
for(size_t i = 2; i < n; i+=2) {
for(size_t j = 0; j < n; ++j) {
if( j < n/2+i/2 ) {
table[i][j] = table[i+1][j] = zone;
}
else {
table[i][j] = table[i+1][j] = zone+1;
}
}
zone+=2;
}
freopen("sah.out","w",stdout);
for(size_t i = 0; i < n; ++i) {
for(size_t j = 0; j < n; ++j) {
printf("%d ",table[i][j]);
}
printf("\n");
}
}