Problem:


Score : 300 points

Problem Statement

You are given an integer sequence of length n, a_1, ..., a_n.
Let us consider performing the following n operations on an empty sequence b.

The i-th operation is as follows:

Append a_i to the end of b.

Reverse the order of the elements in b.

Find the sequence b obtained after these n operations.

Constraints

1 \leq n \leq 2\times 10^5

0 \leq a_i \leq 10^9

n and a_i are integers.

Input

Input is given from Standard Input in the following format:

n
a_1 a_2 ... a_n

Output

Print n integers in a line with spaces in between.
The i-th integer should be b_i.

Sample Input 1

4
1 2 3 4

Sample Output 1

4 2 1 3

After step 1 of the first operation, b becomes: 1.

After step 2 of the first operation, b becomes: 1.

After step 1 of the second operation, b becomes: 1, 2.

After step 2 of the second operation, b becomes: 2, 1.

After step 1 of the third operation, b becomes: 2, 1, 3.

After step 2 of the third operation, b becomes: 3, 1, 2.

After step 1 of the fourth operation, b becomes: 3, 1, 2, 4.

After step 2 of the fourth operation, b becomes: 4, 2, 1, 3.

Thus, the answer is 4 2 1 3.

Sample Input 2

3
1 2 3

Sample Output 2

3 1 2

As shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third operation. Thus, the answer is 3 1 2.

Sample Input 3

1
1000000000

Sample Output 3

1000000000

Sample Input 4

6
0 6 7 6 7 0

Sample Output 4

0 6 6 0 7 7



Sample input:
4
1 2 3 4


Sample output:
4 2 1 3

Submission status: Accepted

Solution code:
n=int(input())

a=list(map(int,input().split()))
b=[0]*n
cen=n//2
if n%2:#n%2==1
    for i in range(0,n):
        if i%2==1:
            b[cen+(i+1)//2]=a[i]
        else:
            b[cen-(i+1)//2]=a[i]
else:
    for i in range(0,n):
        if i%2==1:
            b[cen-(i+1)//2]=a[i]
        else:
            b[cen+(i+1)//2]=a[i]
"""
for i in range(n):
    b.append(a[i])
    b.reverse()
"""
for i in range(n):
    print(b[i],end=" ")

Submission status: Accepted

Solution code:
import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce
import sys
sys.setrecursionlimit(4100000)

n = int(input())
a = list(map(int, input().split()))
ans = [-1] * (2 *10 ** 5 + 1)
left = False
right = False
if n % 2 == 0:
    left = True
else:
    right = True
start = n // 2
ans[start] = a[0]
for i in range(1, n):
    if left:
        ans[start - i] = a[i]
        start -= i
        left = False
        right = True
    else:
        ans[start + i] = a[i]
        start += i
        left = True
        right = False
for i in range(n):
    print(ans[i], " ", sep="", end="")

Submission status: Accepted

Solution code:
import sys
read_=sys.stdin.buffer.readline
N=int(read_())
A=input().split()
if len(A)==1:
    print(A[0])
    exit()
if N%2==0:
    ans=A[1::2][::-1]
    ans.extend(A[::2])
else:
    ans=A[::2][::-1]
    ans.extend(A[1::2])
print(' '.join(ans))

Submission status: Accepted

Solution code:
import sys
read_=sys.stdin.buffer.readline

N=int(read_())
A=input().split()

if len(A)==1:
    print(A[0])
    exit()

B1=A[::2]
B2=A[1::2]

if N%2==0:
    B2.reverse()
    B2.extend(B1)
    print(' '.join(B2))
else:
    B1.reverse()
    B1.extend(B2)
    print(' '.join(B1))

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
a = list(map(int, input().split()))

d = deque()
for i, v in enumerate(a):
    if i % 2 == 0:
        d.appendleft(v)
    else:
        d.append(v)
if i % 2 == 1:
    d = list(d)[::-1]
print(*d, sep=' ')

Submission status: Accepted

Solution code:
from math import ceil
n = int(input())
a = list(map(int, input().split()))
a.reverse()
b = [0] * n
for i in range(n):
    if i % 2 == 0:
        b[i//2] = a[i]
    else:
        b[-(ceil(i/2))] = a[i]

#print(b)
for i in range(n):
    print(b[i])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
if len(a)%2 == 1:
    print(*a[0::2][::-1] + a[1::2])
else:
    print(*a[1::2][::-1] + a[0::2])

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

b = np.zeros(n, dtype='int')

cnt = 0
if n % 2 == 0:
    for i in range(n // 2):
        left_idx = n // 2 - 1 - i
        right_idx = n // 2 + i
        b[left_idx] = 2 * i + 1
        b[right_idx] = 2 * i + 2
    b = b[::-1]
else:
    for i in range(n // 2):
        left_idx = n // 2 - i
        right_idx = n // 2 + 1 + i
        b[left_idx] = 2 * i + 1
        b[right_idx] = 2 * i + 2
    b[0] = n
# print('b', b)

for i in a[[b - 1]]:
    print(i)

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
lst1 = list(map(int,input().split()))

p = sum(lst1)

b = deque([])

for i in range(n):
    if i%2 == 0:
        b.appendleft(lst1[i])
    else:
        b.append(lst1[i])

if n%2==0:
    b.reverse()
    print(*b)
else:
    print(*b)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]

b = [0] * n
center = n // 2

before = center
if n % 2 != 0:
    for i in range(len(a)):
        if i % 2 != 0:
            before = before + i
        else:
            before = before - i
        b[before] = a[i]
else:
    for i in range(len(a)):
        if i % 2 != 0:
            before = before - i
        else:
            before = before + i
        b[before] = a[i]

b = " ".join(list(map(str, b)))
print(b)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]

length = len(a)
b = [0] * length
center = length // 2

if len(a) % 2 != 0:
    before = center
    for i in range(len(a)):
        if i == 0:
            b[center] = a[i]
        else:
            if i % 2 != 0:
                before = before + i
            else:
                before = before - i
            b[before] = a[i]
else:
    before = center
    for i in range(len(a)):
        if i == 0:
            b[center] = a[i]
        else:
            if i % 2 != 0:
                before = before - i
            else:
                before = before + i
            b[before] = a[i]


L = [str(v) for v in b]
L = ' '.join(L)
print(L)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in input().split()]

even = []
odd = []

for i in range(n):
    if i % 2 == 0:
        odd.append(a[i])
    else:
        even.append(a[i])

if n % 2 == 0:
    even.reverse()
    ans = even + odd
    print(*ans)
else:
    odd.reverse()
    ans = odd + even
    print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
lst = [x for x in input().split()]

lst1 = lst[0::2]
lst2 = lst[1::2]

if n % 2 == 0:
    lst2.reverse()
    ret = lst2 + lst1
else:
    lst1.reverse()
    ret = lst1 + lst2

print(" ".join(ret))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))

B = []
T = []

if N % 2 == 0:
  for index, a in enumerate(A):
    if index % 2 == 1:
      T.append(a)
    else:
      B.append(a)
else:
  for index, a in enumerate(A):
    if index % 2 == 0:
      T.append(a)
    else:
      B.append(a)

T.reverse()
T.extend(B)


for b in T:
  print(b, end=" ")

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
odd = a[::2]
even = a[1::2]
even.reverse()
ans = even + odd
if n % 2:
  ans.reverse()
  
print(" ".join(list(map(str, ans))))

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
if n % 2 == 0:
    ans = [l[i] for i in range(n-1,-1,-2)] + [l[i] for i in range(0,n-1,2)]
    print(*ans)
else:
    ans = [l[i] for i in range(n-1,-1,-2)] + [l[i] for i in range(1,n-1,2)]
    print(*ans)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(x) for x in input().split()]

t = []

for i in range(N)[::-1]:
	if i%2!=(N%2):
		t.append(A[i])

for i in range(N):
	if i%2==(N%2):
		t.append(A[i])



print(*t)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
ans = []
if n == 1: print(a[0])
else:
    for i in a[::-2]:
        ans.append(i)
    if n % 2 == 0:
        for i in a[::2]:
            ans.append(i)
    else:
        for i in a[1::2]:
            ans.append(i)
print(*ans)

Submission status: Accepted

Solution code:
l1 = []
l2 = []
n = int(input())
a = list(map(int, input().split()))
flag = -1
for i in range(n):
    if flag < 0:
        l1.append(a[i])
    else:
        l2.append(a[i])
    flag *= -1
if n%2 == 0:
    print(*(list(reversed(l2))+l1))
else:
    print(*(list(reversed(l1))+l2))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = []
if n % 2 == 0:
    for i in range(n // 2):
        b.append(a[- 2 * i - 1])
    for i in range(n // 2):
        b.append(a[2 * i])
else:
    for i in range(n // 2 + 1):
        b.append(a[- 2 * i - 1])
    for i in range(n // 2):
        b.append(a[2 * i + 1])
print(*b)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))

o=[]
e=[]
for i in range(n):
    if i%2==0:
        o.append(a[i])
    if i%2==1:
        e.append(a[i])

if n%2==0:
    E=[]
    for i in range(n//2):
        E.append(e[n//2-1-i])
    ans = []
    for i in range(n//2):
        ans.append(E[i])

    for i in range(n//2):
        ans.append(o[i])
    s = ""
    for i in range(len(ans)):
        s = s+str(ans[i])
        s = s+" "
    print(s)
    exit()
else:
    O=[]
    for i in range(len(o)):
        O.append(o[len(o)-1-i])
    ans = []
    for i in range(len(O)):
        ans.append(O[i])
    for i in range(n//2):
        ans.append(e[i])
    s = ""
    for i in range(len(ans)):
        s = s+str(ans[i])
        s = s+" "
    print(s)
    exit()

Submission status: Accepted

Solution code:
n = int(input())
S = list(map(int, input().split()))
S=S[::-1]
x=S[::2]
y=S[1::2]
b=x+y[::-1]
print(*b, sep=" ")

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))

res=[]
for i in range(len(D)-1,0,-2):
    res.append(D[i])
res.append(D[0])
start=(N+1)%2+1
for i in range(start,len(D),2):
    res.append(D[i])

for i in res:
    print(i,end=" ")

Submission status: Accepted

Solution code:
from collections import deque

def main():
    input()
    A = list(enumerate(input().split()))
    b = deque()
    (append1, append2) = (b.append, b.appendleft) if len(A) % 2 == 0 else (b.appendleft, b.append)
    for i, a in A:
        if i % 2 == 0:
            append1(a) 
        else:
            append2(a)

    print(" ".join(list(b)))

main()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

s = [a[i] for i in range(0,n,2)]
t = [a[i] for i in range(1,n,2)[::-1]]
if n % 2 == 0:
    print(*t, end=' ')
    print(*s)
else:
    # print(s,t)
    print(*s[::-1], end=' ')
    print(*t[::-1])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
if len(a) == 1:
    res = a[0]
elif len(a) % 2 == 0:
    res = " ".join(map(str, a[-1::-2] + a[::2]))
else:
    res = " ".join(map(str, a[-1::-2] + a[1::2]))
print(res)

Submission status: Accepted

Solution code:
from collections import deque

def main():
    input()
    A = list(enumerate(input().split()))
    size = len(A)
    b = deque()
    for i, a in A:
        if i % 2 == 0:
            if size % 2 == 0:
                b.append(a)
            else:
                b.appendleft(a)    
        else:
            if size % 2 == 0:
                b.appendleft(a)
            else:
                b.append(a)

    print(" ".join(list(b)))

main()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))


a_odd = a[::2]
a_even = a[1::2]

if n % 2 == 0:
    ans = a_even[::-1]
    ans.extend(a_odd)
else:
    ans = a_odd[::-1]
    ans.extend(a_even)

print(*ans)

Submission status: Accepted

Solution code:
from collections import deque
d = deque()
n = int(input())
alist = list(map(int, input().split()))
for i in range(n):
    if i % 2 == 0:
        d.append(alist[i])
    else:
        d.appendleft(alist[i])
if n % 2 == 0:
    d = list(d)
else:
    d = list(d)[::-1]
for element in d:
    print(element, end=" ")
print()

Submission status: Accepted

Solution code:
n = int(input())
A = [int(x) for x in input().split()]
B = []
if n % 2 == 0:
    for i in range(n // 2, 0, -1):
        B.append(A[2 * i - 1])
    for j in range(n // 2):
        B.append(A[2*j])
else:
    for k in range(n // 2, -1, -1):
        B.append(A[2 * k])
    for h in range(1, n // 2+1):
        B.append(A[2*h-1])


print(*B, sep=" ")

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
if n%2==1:
    print(*(a[::-2]+a[1::2]))
if n%2==0:
    print(*(a[::-2]+a[0::2]))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

b = [-1] * (n + 2)

mid = n // 2
left = mid - 1
right = mid + 1

b[mid] = a[0]

for i in range(1, n):
  if not i % 2 == n % 2:
    b[left] = a[i]
    left -= 1
  else:
    b[right] = a[i]
    right += 1

for i in b:
  if i < 0:
    continue
  print(i, end=" ")

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[]
C=[]
for i in range(N):
  if i%2==0:
    B.append(A[i])
  else:
    C.append(A[i])
D=B[::-1]
E=C[::-1]
if N%2==0:
  print(*(E+B))
else:
  print(*(D+C))

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
a = list(map(int, input().split()))

b = deque()
if n % 2 == 0:
    for i in range(n):
        if i % 2 == 0:
            b.append(a[i])
        else:
            b.appendleft(a[i])
else:
    b.appendleft(a[0])
    for i in range(1, n):
        if not i % 2 == 0:
            b.append(a[i])
        else:
            b.appendleft(a[i])

for i in range(len(b)):
    print(b[i], end=" ")

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = []

if n % 2 == 0:
    for i in range(n - 1, 0, -2):
        b.append(a[i])
    for i in range(0, n, 2):
        b.append(a[i])
else:
    for i in range(n - 1, -1, -2):
        b.append(a[i])
    for i in range(1, n, 2):
        b.append(a[i])

for i in range(len(b)):
    print(b[i], end=" ")

Submission status: Accepted

Solution code:
# coding: utf-8
n=int(input())
A=list(map(int,input().split()))
l=[]
r=[]
k=1
for i in range(n):
    if i%2==0:
        r.append("{}".format(A[i]))
    else:
        l.append("{}".format(A[i]))
l.reverse()

b=l+r

if n%2==1:
    b.reverse()

print(" ".join(b))

Submission status: Accepted

Solution code:
# coding: utf-8
n=int(input())
A=list(map(int,input().split()))
B=[0]*n
l=n//2
if n%2==0:
    for i in range(n):
        if i%2==0:
            B[l+i]=str(A[i])
            l=l+i
        else:
            B[l-i]=str(A[i])
            l=l-i
else:
    for i in range(n):
        if i%2==0:
            B[l-i]=str(A[i])
            l=l-i
        else:
            B[l+i]=str(A[i])
            l=l+i
print(' '.join(B))

Submission status: Accepted

Solution code:
N=int(input())
A=list(input().split())
s = " ".join(A[::-2]) + " " + " ".join(A[N%2::2])
print(s)

Submission status: Accepted

Solution code:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
if N % 2 != 0:
    for i in range(N-1, -1, -2):
        print(A[i], end=" ")
    for i in range(1, N, 2):
        print(A[i], end=" ")
else:
    for i in range(N-1, 0, -2):
        print(A[i], end=" ")
    for i in range(0, N, 2):
        print(A[i], end=" ")

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
A = deque(map(int, input().split()))
B = deque()

if n%2==0:
  while(A):
    B.append(A.popleft())
    B.appendleft(A.popleft())
else:
  while(A):
    B.appendleft(A.popleft())
    if(A):
      B.append(A.popleft())

for i in range(n):
  print(B[i], end=" ")

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
dList = list(map(int,input().split()))
result = deque()

for i in range(n):
  if i % 2 == n % 2:
   result.append(dList[i])
  else:
   result.appendleft(dList[i])

for i in result:
  print(i,end=" ")

print()

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
dList = list(map(int,input().split()))
result = deque()

for i in range(n):
  if (i % 2 == 0 and n % 2 == 0) or (i % 2 != 0 and n % 2 != 0):
   result.append(dList[i])
  else:
   result.appendleft(dList[i])

for i in result:
  print(i,end=" ")

print()

Submission status: Accepted

Solution code:
from collections import deque

N = int(input())
A = list(map(int, input().split()))

d = deque()

if N % 2 == 0:
	for i in range(N):
		if (i + 1) % 2 == 1:
			d.append(A[i])
		else:
			d.appendleft(A[i])
else:
	for i in range(N):
		if (i + 1) % 2 == 1:
			d.appendleft(A[i])
		else:
			d.append(A[i])
			
print(*d)

Submission status: Accepted

Solution code:
def solve(n, A):
    return [A[n - 2 * i - 1] if i < n / 2 else A[2 * i - n] for i, a in enumerate(A)]

_n = int(input())
_A = list(map(int, input().split()))
print(*solve(_n, _A))

Submission status: Accepted

Solution code:
N = int(input())
lst = list(map(int,input().split()))
lst.reverse()
lst2 = [0] * N
for idx,i in enumerate(lst):
  if (idx % 2 == 0):
    lst2[idx // 2] = i
  else:
    lst2[N-(idx // 2)-1] = i
print(" ".join(map(str,lst2)))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = []
ans1 = a[0::2]
ans2 = a[1::2]
if n%2 == 0:
    ans2.reverse()
    b.extend(ans2)
    b.extend(ans1)
    print(*b)
else:
    ans1.reverse()
    b.extend(ans1)
    b.extend(ans2)
    print(*b)

Submission status: Accepted

Solution code:
n = int(input())
*a, = map(int, input().split())

right = a[1::2]
right.reverse()
left =  a[0::2]

b = []
b.extend(right)
b.extend(left)

if n%2 == 1:
    b.reverse()

print(*b)

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
a = list(map(int, input().split()))

b = deque()


for i in range(n):
    if i % 2 == 0:
        b.appendleft(a[i])
    else:
        b.append(a[i])
if n % 2 == 0:
    b = list(b)[::-1]
print(*b)

Submission status: Accepted

Solution code:
n,p=int(input()),list(map(int,input().split()))
k= n//2 if n%2==0 else n//2+1
a,b=list(range(0,k)),list(range(k-1,n))[::-1]
c=[]
for x,y in zip(a,b):
  c.append(x)
  c.append(y)
c= c if n%2==0 else c[:-1]
c=c[::-1]
l=list([])
for x,y in zip(c,list(range(n))):
  l.append([x,y])
l=sorted(l)
for i in range(n):
  print(p[l[i][1]],end=" ")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
a = list(map(int,input().split()))

if n % 2:
    for i in a[-1::-2]:
        print(i,end=" ")
    for i in a[1::2]:
        print(i,end=" ")
else:
    for i in a[-1::-2]:
        print(i,end=" ")
    for i in a[0::2]:
        print(i,end=" ")

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
a = list(map(int,input().split()))
b = deque()
for i in range(n):
    if ((i+1) % 2) == (n % 2):
        b.appendleft(a[i])
    else:
        b.append(a[i])
ans = ' '.join([str(i) for i in b])
print(ans)

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
a = list(map(int,input().split()))
b = deque()
for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
if n % 2 == 1:
    b.reverse()
print(' '.join(map(str, b)))

Submission status: Accepted

Solution code:
import sys
import collections

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    B = collections.deque()

    for i, a in enumerate(A):
        if i & 1:
            B.appendleft(a)
        else:
            B.append(a)

    if N & 1:
        print(*reversed(B))
    else:
        print(*B)

    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import deque

N = int(input())
A = list(map(int, input().split()))

answer = deque([])
for i, a in enumerate(A):
  if i % 2 == 0:
    answer.appendleft(a)
  else:
    answer.append(a)
    
answer = list(answer)
answer = answer if N % 2 else answer[::-1]

print(*answer)

Submission status: Accepted

Solution code:
from collections import deque
d = deque()
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    if i % 2 == 0:
        d.append(a[i])
    else:
        d.appendleft(a[i])

if n % 2 == 1:
    d.reverse()

for i in d:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

if n % 2 == 0:
    sk = 0
else:
    sk = 1
b = a[::-2] + a[sk::2]

print(*b)

Submission status: Accepted

Solution code:
from collections import deque
N = int(input())
A = list(map(int, input().split()))
B = deque([])
i = 0
if N & 1:
    B.appendleft(A[i])
    i += 1
while i < N:
    B.append(A[i])
    i += 1
    B.appendleft(A[i])
    i += 1
print(*B)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
ki=a[0::2]
ki2=[]
for i in ki[::-1]:
    ki2.append(i)
guu=a[1::2]
guu2=[]
for i in guu[::-1]:
    guu2.append(i)

if n%2==0:
    kotae=guu2+ki
else:
    kotae=ki2+guu
kotae=" ".join(map(str,kotae))
print(kotae)

Submission status: Accepted

Solution code:

n = int(input())
a = list(map(int, input().split()))

if n % 2 == 0:
  ans = a[1::2][::-1] + a[::2]
  print(*ans)
else:
  ans = a[::2][::-1] + a[1::2]
  print(*ans)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
A = LIST()

que = deque([])
for i, a in enumerate(A):
    j = i + 1
    # 偶奇同じ
    if (n - j) % 2 == 0:
        que.appendleft(a)
    else:
        que.append(a)
print(*que)

Submission status: Accepted

Solution code:
from collections import deque

N = int(input())
a = list(map(int, input().split()))

b = deque()

if N % 2 == 0:
    for i in range(0, N, 2):
        b.append(a[i])

    for i in range(1, N, 2):
        b.appendleft(a[i])
else:
    for i in range(0, N, 2):
        b.appendleft(a[i])

    for i in range(1, N, 2):
        b.append(a[i])

print(*b)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
a = LIST()

tmp1 = []
tmp2 = []

for i, a in enumerate(a):
    if i%2 == 0:
        tmp1.append(a)
    else:
        tmp2.append(a)
if n%2 == 0:
    print(*(tmp2[::-1]+tmp1))
else:
    print(*(tmp1[::-1]+tmp2))

Submission status: Accepted

Solution code:
"""TLE
N = int(input())
sequence = list(input().split())
ans = []
for i in range(N):
    a_i = sequence[i]
    ans.append(a_i)
    ans = ans[::-1]
print(" ".join(ans))
"""

from collections import deque
n = int(input())
sequence = deque(map(int,input().split()))
ans = deque()
if n % 2 == 1:
    for i in range(n):
        if i % 2 == 0:
            ans.appendleft(sequence[0])
        else:
            ans.append(sequence[0])
        sequence.popleft()
        #print(ans)
else:
    for i in range(n):
        if i % 2 == 1:
            ans.appendleft(sequence[0])
        else:
            ans.append(sequence[0])
        sequence.popleft()
        #print(ans)
print(*ans)

Submission status: Accepted

Solution code:
n=int(input())
a=input().split()
a_even=[a[i] for i in range(0,n,2)]
a_odd=[a[i] for i in range(1,n,2)]

if n%2==1:
    a_even.reverse()
    ans=' '.join(a_even) +' ' + ' '.join(a_odd)
    print(ans)
else:
    a_odd.reverse()
    ans=' '.join(a_odd)+' '+' '.join(a_even)
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
b = [0] * n
for i in range(n):
    j = n - i * 2 - 1
    if j < 0:
        j = -j - 1
    b[i] = a[j]
print(*b)

Submission status: Accepted

Solution code:
n = int(input())
nums = [i for i in input().split()]

ans = nums[1::2][::-1] + nums[::2]
if n == 1:
    print(''.join(nums))
elif n % 2 != 0:
    print(' '.join(ans[::-1]))
else:
    print(' '.join(ans))

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
a = list(map(int, input().split()))
b = deque()
for i in range(n):
    if i % 2 == n % 2:
        b.append(a[i])
    else:
        b.appendleft(a[i])

print(*list(b))

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
from collections import deque

B = deque()

if len(A) %2 ==0:
    for idx, a in enumerate(A):

        if idx % 2 == 0:
            B.append(a)
        else:
            B.appendleft(a)

else:
    for idx, a in enumerate(A):

        if idx % 2 == 0:
            B.appendleft(a)
        else:
            B.append(a)
print(*B)

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
a = list(map(int, input().split()))

b = deque()

for i in range(n):
    if i % 2 == n % 2:
        b.append(a[i])
    else:
        b.appendleft(a[i])


print(*list(b))

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n = I()
    a = LI()
    even = False
    if n % 2 == 0:
        even = True
    N = n
    ans = []
    if even:
        # [6, 4, 2, 1, 3, 5]
        while N > 1:
            ans.append(a[N-1])
            N = N - 2
        N = 1
        while N < n:
            ans.append(a[N-1])
            N = N + 2
    else:
        # [5, 3, 1, 2, 4]
        while N > 0:
            ans.append(a[N-1])
            N = N - 2
        N = 2
        while N <= n:
            ans.append(a[N-1])
            N = N + 2
    for a in ans:
        print(a, end=' ')
    print()

main()

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ki=[]
gu=[]
for i in range(n):
  if i%2:
    ki.append(a[i])
  else:
    gu.append(a[i])
#print(ki,gu)
if n%2==0:
  ki.reverse()
  ki.extend(gu)
  print(*ki)
else:
  gu.reverse()
  gu.extend(ki)
  print(*gu)

Submission status: Accepted

Solution code:
n = int(input())
number_list = list(map(int,input().split()))

a = n-1
step = -2
ans = []

for i in range(n):
    ans.append(number_list[a])
    
    a += step
    
    if a == -1:
        a=0
        step=2
    elif a == -2:
        a=1
        step=2
    
print(' '.join(map(str,ans)))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = []
if n%2==0:
  front = a[::2]
  back = a[1::2][::-1]
else:
  front = a[1::2]
  back = a[::2][::-1]
ans = back+front
print(*ans)

Submission status: Accepted

Solution code:

N = int(input())
A = list(map(int, input().split()))


if N % 2 == 0:
  latter = A[0:N:2]
  former = A[1:N:2][::-1]
  print(*(former + latter))
else:
  former = A[0:N:2][::-1]
  latter = A[1:N:2]
  print(*(former + latter))

Submission status: Accepted

Solution code:
n = int(input())
a = list(input().split())
if n % 2 == 0:
    print(" ".join(a[1::2][::-1] + a[0::2]))
else:
    print(" ".join(a[0::2][::-1] + a[1::2]))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
a_odd = a[0::2]
a_even = a[1::2]
if n % 2 == 0:
    print(*(a_even[::-1] + a_odd))
else:
    print(*(a_odd[::-1] + a_even))

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
a = deque(map(int, input().split()))
b = deque()

if n % 2 == 1:
    for i in range(n):
        if i % 2 == 0:
            b.appendleft(a.popleft())
        else:
            b.append(a.popleft())
else:
    for i in range(n):
        if i % 2 == 0:
            b.append(a.popleft())
        else:
            b.appendleft(a.popleft())

print(*b)

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))

front=[]
end=[]

for i in range(N):
    if i%2==0:
        end.append(A[i])
    else:
        front.append(A[i])

front.reverse()
data=front+end
if N%2==1:
    data.reverse()
data=list(map(str,data))
print(" ".join(data))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
from collections import deque
que=deque()
for i in range(n):
    if i%2==0:
        que.append(a[i])
    else:
        que.appendleft(a[i])
if n%2==0:
    print(*list(que))
else:
    print(*list(que)[::-1])

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))

if N == 1:
  print(A[0])
else:
  print(*A[::-2], end=" ")
  print(*A[N%2::2])

Submission status: Accepted

Solution code:
from collections import deque
N = int(input())
a = list(map(int, input().split()))
ans = deque([])
for i in range(N):
    if (i+1) % 2 == N % 2:
        ans.appendleft(a[i])
    else:
        ans.append(a[i])
print(*ans, sep=" ")

Submission status: Accepted

Solution code:

N = int(input())
A = list(map(int, input().split()))

B = [0] * N
if N % 2 == 0:
  for i in range(N):
    if i % 2 == 0:
      B[N//2+i//2] = A[i]
    else:
      B[N//2-(i//2+1)] = A[i]
else:
  for i in range(N):
    if i % 2 == 1:
      B[N//2+(i//2+1)] = A[i]
    else:
      B[N//2-(i//2)] = A[i]

print(*B)

Submission status: Accepted

Solution code:
n = int(input())
arr = input().split()
arr = list(map(int,arr))

b = [0] * n
center = n // 2
for i in range(n):
    if i % 2 == 0:
        b[center + (i//2)] = arr[i]
    else:
        b[center - ((i+1)//2)] = arr[i]

if n % 2 == 0:
    pass
else:
    b.reverse()

for i in range(n-1):
    print(b[i], end = ' ')
print(b[-1])

Submission status: Accepted

Solution code:
import sys
from collections import deque
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
b_ls = deque([])
for i, a in enumerate(a_ls):
    if i % 2 == 0:
        b_ls.append(a)
    else:
        b_ls.appendleft(a)
if n % 2 == 1:
    b_ls.reverse()
print(" ".join([str(i) for i in b_ls]))