-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC.cpp
More file actions
53 lines (53 loc) · 1.13 KB
/
C.cpp
File metadata and controls
53 lines (53 loc) · 1.13 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
49
50
51
52
53
#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define ll long long
#define Speedo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define return0 return 0
#define Endl endl
#define ull unsigned long long
#define elif else if
#define test cout<<" We Fucked up Here Boss_________________"<<endl
#define allout(first) for(auto ele : first) {cout<<ele<<" ";}cout<<endl;
void solve()
{
int n;
cin >> n;
if (n == 2) {
cout << -1 << endl; return;
}
int cnt = 0;
for (int i = 1; i <= n*n; i++)
{
if (i % 2 == 0) {
cnt++;
cout << i << " ";
if (cnt % n == 0) {
cout << endl;
}
}
}
for (int i = 1; i <= n * n; i++)
{
if (i % 2 != 0) {
cnt++;
cout << i << " ";
if (cnt % n == 0) {
cout << endl;
}
}
}
}
int main()
{
Speedo;
int t;
cin >> t;
while (t--)
{
solve();
}
}