-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patholliePS-342.cpp
63 lines (59 loc) · 994 Bytes
/
olliePS-342.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
60
61
62
63
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define reverse_flash() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const long long int MOD = 1e9 + 7;
const long long int INF = 1e18;
const long long int MAX = 1e9;
void solution()
{
ll n;
cin >> n;
cout << n << " ";
ll i , j = n-1;
if(n % 2 == 0)
{
i = n/2 - 1;
}
else
{
i = n/2;
}
ll turn = 0 , mid = i + 1;
while(i > 0 && j > mid)
{
if(turn % 2 == 0)
{
cout << i << " ";
i--;
}
else
{
cout << j << " ";
j--;
}
turn++;
}
if(turn % 2 == 1)
{
cout << j << " " << mid << endl;
return;
}
if(i != 0)
{
cout << i << " ";
}
cout << mid << endl;
return;
}
int main()
{
reverse_flash();
ll t;
cin >> t;
while (t--)
{
solution();
}
return 0;
}