-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathEqual LIS.cpp
50 lines (44 loc) · 1.02 KB
/
Equal LIS.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
// Problem Link : https://www.codechef.com/START22B/problems/EQLIS
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
int t;
cin >> t;
for (int z = 1; z <= t; z++){
int n;
cin >> n;
if(n == 2){
cout << "NO\n";
}else{
cout << "YES\n";
int arr[n];
int temp = 1;
int pos = 0;
for(int i = 0; i < n/2; i++){
arr[pos] = temp;
pos++;
temp += 2;
}
if(n%2 == 1){
arr[pos] = n;
pos++;
}
temp = n/2*2;
for(int i = 0; i < n/2; i++){
arr[pos] = temp;
pos++;
temp -= 2;
}
if(n%2 == 0){
swap(arr[0],arr[1]);
}
for(int i = 0; i < n; i++){
cout << arr[i] << " ";
}
cout << endl;
}
}
return 0;
}