-
Notifications
You must be signed in to change notification settings - Fork 62
/
SNACKUP.cpp
59 lines (52 loc) · 893 Bytes
/
SNACKUP.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Code written by Monal
#include "bits/stdc++.h"
using namespace std;
void call_even(int n) {
int j = 1;
for (int i = 1; i <= n; i += 2) {
cout<<n<<"\n";
for (int k = 1; k <= n; ++k) {
cout<<k<<" "<<j<<" "<<j+1<<"\n";
}
cout<<n<<"\n";
for (int k = 1; k <= n; ++k) {
cout<<k<<" "<<j<<" "<<j+1<<"\n";
}
j += 2;
}
}
void call_odd(int n) {
int j = 1;
for (int i = 1; i <= n; ++i) {
cout<<n<<"\n";
for (int k = 1; k <= n; ++k) {
cout<<k<<" "<<i<<" ";
if (i != n)
cout<<i+1;
else
cout<<1;
cout<<"\n";
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int tc;
cin>>tc;
while (tc--) {
int n;
cin>>n;
//vector <bool> init (n, false);
//vector < vector <bool> > arr (n, vector <bool> (n, false));
cout<<n<<"\n";
if (n % 2 == 0) {
call_even(n);
}
else {
call_odd(n);
}
//arr.clear();
}
return 0;
}