-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1436B.cpp
43 lines (36 loc) · 854 Bytes
/
1436B.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
43
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
vector <vector <int> > a(n);
for (int i = 0; i < n; ++i) {
a[i].resize(n, 0);
}
if (n == 4) {
vector <vector <int> > matrix = {{4, 6, 8, 1}, {4, 9, 9, 9}, {4, 10, 10, 65}, {1, 4, 4, 4}};
cout << "4 6 8 1\n4 9 9 9\n4 10 10 65\n1 4 4 4\n";
continue;
}
for(int i=0;i<n;i++)
{a[i][i]=1; a[i][n-i-1]=1;}
if(n%2)
{
a[n/2][n/2+1]=1;
a[n/2 -1][n/2]=1;
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
cout<<a[i][j]<<" ";
}
cout<<"\n";
}
}
}