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()))
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(str,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 == 0:
    print(" ".join(b))
else:
    b.reverse()
    print(" ".join(b))

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:
    for i in range(n):
        if i%2==0:
            b.appendleft(a[i])
        else:
            b.append(a[i])

print(*b)

Submission status: Accepted

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

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

ans = []
if n%2==0:
    for i in range(n//2):        
        ans.append(li2[(i+1)*(-1)])
    for i in range(n//2): 
        ans.append(li1[i])

else:
    for i in range(n//2+1):        
        ans.append(li1[(i+1)*(-1)])
    for i in range(n//2): 
        ans.append(li2[i])

print(*ans)

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
A = list(map(int, input().split()))
deq = deque([])

for i in range(1, n+1):
    if i % 2 == 1:
        deq.append(A[i-1])
    else:
        deq.appendleft(A[i-1])

if n % 2 == 0:
    print(*deq)
else:
    print(*reversed(list(deq)))

Submission status: Accepted

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

ls_odd = []
ls_even = []

for i in range(n):
    if i % 2 == 0:
        ls_odd.append(ls[i])
    elif i % 2 == 1:
        ls_even.append(ls[i])

if n % 2 == 0:
    ls_even.reverse()
    ans = ls_even + ls_odd
elif n % 2 == 1:
    ls_odd.reverse()
    ans = ls_odd + ls_even

print(" ".join((map(str, ans))))

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])

ans = []
if N % 2 == 0:
    C.reverse()
    ans = C + B
else:
    B.reverse()
    ans = B + C

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 == n%2:
        b.extend([a[i]])
    else:
        b.extendleft([a[i]])
print(*list(b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
N = int(input())
S = input().split()
B = deque()

for i in range(N):
  if i%2==0:
    B.append(S[i])
  else:
    B.appendleft(S[i])

if N%2 == 1:
  B.reverse()
print(*B)

Submission status: Accepted

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

Submission status: Accepted

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

if len(a)%2==0:
    b=a[::-2]+a[::2]
else:
    b=a[::-2] + a[1::2]

print(' '.join(list(map(str,b))))

Submission status: Accepted

Solution code:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
	n = int(input())
	a = list(map(int,input().split()))
	ans = list(reversed([a[i] for i in range(1 if n%2==0 else 0,n,2)])) + [a[i] for i in  range(0 if n%2==0 else 1,n,2)]
	for i in ans:
		print(i,end=' ')
	print()

main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import collections
N=int(input())
L=list(map(int,input().split()))
d = collections.deque([str(L[0])])
NN = N % 2
for i in range(1,N):
  if NN == 0:
    if i % 2 == 0:
      d.append(str(L[i]))
    else:
      d.appendleft(str(L[i]))
  else:
    if i % 2 == 0:
      d.appendleft(str(L[i]))
    else:
      d.append(str(L[i]))
print(' '.join(list(d)))

Submission status: Accepted

Solution code:
def main():
    n=int(input())
    A=list(map(int,input().split()))
    B=[0]*n
    for i in range(n):
        B[(-(-i//2))*(-1)**(i)]=A[-i-1]
    print(*B)
main()

Submission status: Accepted

Solution code:
import sys
from collections import deque

input = sys.stdin.readline


n = int(input())
a = 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 = list(b)[::-1]
print(' '.join(b))

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int, input().split()))
out=[0]*n
i=0
j=n-1
k=n-1
while i<=j:
  out[i]=a[k]
  k-=1
  i+=1
  if k<0:
    break
  out[j]=a[k]
  k-=1
  j-=1
print(*out)

Submission status: Accepted

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

ans = []
if N % 2 == 0:
    order = 0
    reverse = N-1
    for i in range(N//2):
        ans.append(a[reverse])
        reverse -= 2
    for i in range(N//2):
        ans.append(a[order])
        order += 2
else:
    order = 1
    reverse = N-1
    for i in range(N//2+1):
        ans.append(a[reverse])
        reverse -= 2
    for i in range(N//2):
        ans.append(a[order])
        order += 2

print(*ans)

Submission status: Accepted

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

b=[]
c=[]
if n%2==0:
    for i in range(n):
        if i%2==0:
            b.append(a[i])
        else:
            c.append(a[i])
else:
    for i in range(n):
        if i%2==0:
            c.append(a[i])
        else:
            b.append(a[i])
c=c[::-1]
print(" ".join(c)+" "+" ".join(b))

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:
    for i in range(N):
        if i % 2 == 0:
            B.appendleft(A[i])
        else:
            B.append(A[i])

print(*B)

Submission status: Accepted

Solution code:
import math

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

ans = [0] * n
if (n % 2 == 0):
    for i in range(n):
        if (i%2 == 0):
            ans[n//2+i//2] = A[i]
        else:
            ans[n//2-(i+2)//2] = A[i]
if (n % 2 != 0):
    for i in range(n):
        if (i%2 == 0):
            ans[n//2-i//2] = A[i]
        else:
            ans[n//2+(i+2)//2] = A[i]

print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
input_list = list(map(int, input().split()))
ans_list = input_list[::-2] + input_list[n%2::2]
print(*ans_list)

Submission status: Accepted

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

Submission status: Accepted

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

odd = []
even = []
for n in range(N):
    if n % 2 == 0:
        even.append(A[n])
    if n % 2 == 1:
        odd.append(A[n])

oppodd = odd[::-1]
oppeven = even[::-1]
#print(*oppeven)
#print(*oppodd)
if N % 2 != 0:
    B = oppeven + odd
    print(*B)
else:
    B = oppodd + even
    print(*B)
#n-1番目は1番目にくる
#n-2番目はn-1番目にくる
#n-3番目は2番目
#n-4番目は3

Submission status: Accepted

Solution code:
from collections import deque
import sys
input = sys.stdin.readline

n = int(input())
a = deque([int(i) for i in input().split()])
b = deque()

if n % 2 == 0:
    for i,x in enumerate(a):
        if i % 2 == 0:
            b.append(x)
        else:
            b.appendleft(x)
else:
    for i,x in enumerate(a):
        if i % 2 == 0:
            b.appendleft(x)
        else:
            b.append(x)

print(*b)

Submission status: Accepted

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

list = []

if N % 2 == 0:

    for i in reversed(range(0+1,N,2)):
        list.append(a[i])

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

else:
    for i in reversed(range(0,N, 2)):
        list.append(a[i])

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

print(*list)

Submission status: Accepted

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

Submission status: Accepted

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

tmp = []
index = 0

for i in range(N):
  tmp.append([index, A[i]])
  if N % 2:
    if index <= 0:
      index = - index + 1
    else:
      index *= -1
  else:
    if index >= 0:
      index = - index - 1
    else:
      index *= -1

tmp.sort()
#print("tmp:", tmp)

answer = []
for i in range(N):
  answer.append(tmp[i][1])
print(*answer)

Submission status: Accepted

Solution code:
N = int(input())
S = list(map(int, input().split()))
b = [0 for i in range(N)]
if N % 2 == 0:
  for i in range(N):
    if i % 2 == 0:
      b[(N + i) // 2] = S[i]
    else:
      b[(N - i) // 2] = S[i]
else:
  b[N // 2] = S[0]
  for i in range(1, N):
    if i % 2 == 1:
      b[(N + i) // 2] = S[i]
    else:
      b[(N - i) // 2] = S[i]
for i in range(N - 1):
  print(b[i], end = ' ')
print(b[N - 1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import deque

n, *a = map(int, sys.stdin.read().split())

def main():
    b = deque()
    for i in range(n):
        if i & 1:
            b.appendleft(a[i])
        else:
            b.append(a[i])
    res = list(b)
    if n & 1:
        res = res[::-1]

    return res

if __name__ == '__main__':
    ans = main()
    print(*ans, sep=' ')

Submission status: Accepted

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

from collections import deque
b1 = deque([])
b2 = deque([])

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

Submission status: Accepted

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

Submission status: Accepted

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

if n % 2 == 0:
    for a in list(reversed(al[1::2])) + al[0::2]:
        print(a)
else:
    for a in list(reversed(al[0::2])) + al[1::2]:
        print(a)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
p = []
q = []
if n%2 == 0:
	for i in range(n):
		if i%2 == 0:
			p.append(a[i])
		else:
			q.append(a[i])
	q.reverse()
	q.extend(p)
	print (" ".join(map(str,q)))
else:
	for i in range(n):
		if i%2 == 0:
			p.append(a[i])
		else:
			q.append(a[i])
	p.reverse()
	p.extend(q)
	print (" ".join(map(str,p)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

A_odd = A[::2]
A_even = A[1::2]
if n % 2 == 1:
    can = A_odd[::-1] + A_even
else:
    can = A_even[::-1] + A_odd

ans = ' '.join(can)
print(ans)

Submission status: Accepted

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

ans = [0]*n
for i in range(n):
    ans[i] = a[index[i]]
print(*ans)

Submission status: Accepted

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

Submission status: Accepted

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

Ev = list()
Od = list()

for i in range(n):
    if i % 2 == 1:
        Ev.append(As[i])
    else:
        Od.append(As[i])

# print(Ev)
# print(Od)
if n % 2 == 0:
    Ev = Ev[::-1]
    Ev.extend(Od)
    ans = Ev
else:
    Od = Od[::-1]
    Od.extend(Ev)
    ans = Od

print(*ans)

Submission status: Accepted

Solution code:
import sys
from collections import deque

sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = MAP()

B = deque([])

# print(A, B)

for i in range(N):
	if i%2:
		B.append(A[i])
	else:
		B.appendleft(A[i])
	# print(B)

if not N % 2: B = reversed(B)
print(' '.join(map(str, B)))

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    input()
    aa=LI()
    if len(aa)%2:
        print(*aa[::-2],end=" ")
        print(*aa[1::2])
    else:
        print(*aa[::-2],end=" ")
        print(*aa[::2])
main()

Submission status: Accepted

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

q = deque()

for i in range(N):
  if i % 2:
    q.append(a[i])
  else:
    q.appendleft(a[i])

print(*list(q) if N % 2 else reversed(list(q)))

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
l = map(int, input().split())
ans = deque()
for idx, v in enumerate(l):
  if idx % 2 == 0:
    ans.append(v)
  else:
    ans.appendleft(v)
if len(ans) % 2 == 1:
  ans.reverse()
            
print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
if n % 2 == 0:
    b = a[::-2]
    c = a[::2]
    d = b + c
    for i in d:
        print(i, end=' ')
else:
    b = a[::-2]
    c = a[1::2]
    d = b + c
    for i in d:
        print(i, end=' ')

Submission status: Accepted

Solution code:
n=int(input())
a=list(input().split())
o=[]
e=[]
if n==1:
    print(a[0])
elif n%2==0:
    for i in range(1,n,2):
        e.append(a[i])
    for i in range(0,n,2):
        o.append(a[i])
    e.reverse()
    print(" ".join(e)+" "+" ".join(o))
else:
    x=a[0]
    for i in range(1,n,2):
        e.append(a[i])
    for i in range(2,n,2):
        o.append(a[i])
    o.reverse()
    print(" ".join(o)+" "+x+" "+" ".join(e))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
A_oddList = A[::2]
A_evenList = A[1::2]
A_oddList = A_oddList[::-1]
A_evenList = A_evenList[::-1]

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

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:
  for i in range(n):
    if i%2 == 1:
      b.append(a[i])
    else:
      b.appendleft(a[i])
    
b = list(b)    

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b0=[]
b1=[]
for i,j in enumerate(a):
    if (i+1) % 2 == 1:#奇数
        b1.append(j)
    else:#偶数
        b0.append(j)
        
if len(a) % 2 == 0:#偶数だったら逆
    for i in b0[::-1]:
        print(i,end=" ")
    for i in b1:
        print(i,end=" ")
else:
    for i in b1[::-1]:
        print(i,end=" ")
    for i in b0:
        print(i,end=" ")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

b = []

l = range(n)[::-2]
if n % 2 == 0:
    r = range(n)[::2]
else:
    r = range(n)[1::2]

for i in l:
    b.append(str(a[i]))
for i in r:
    b.append(str(a[i]))
    
print(" ".join(b))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(str, input().split()))
b = []
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 = input().split()

if n % 2 == 1:
    print(" ".join((a[0::2][::-1] + a[1::2])))
else:
    print(" ".join((a[1::2][::-1] + a[0::2])))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
a=a[::-1]
b=[0]*n
x,y=0,1
t=True
for z in a:
    if t:
        b[x]=z
        x+=1
        t=False
    else:
        b[-y]=z
        y+=1
        t=True
print(*b)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
a=a[::-1]
b=[0]*n
x=0
y=1
t=True
for aa in a:
    if t:
        b[x]=aa
        x+=1
        t=False
    else:
        b[-y]=aa
        y+=1
        t=True
print(*b)

Submission status: Accepted

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

if n % 2 == 0:
    b = []
    for i in reversed(range(n // 2)):
        b.append(a[2 * i + 1])
    for i in range(n // 2):
        b.append(a[2 * i])
    print(' '.join([str(_b) for _b in b]))
else:
    b = []
    for i in reversed(range(n // 2 + 1)):
        b.append(a[2 * i])
    for i in range(n // 2):
        b.append(a[2 * i + 1])
    print(' '.join([str(_b) for _b in b]))

Submission status: Accepted

Solution code:
from collections import deque

b = deque()
n=int(input())
a=[i for i in input().split()]
ans=0
for i in range(n):
    if(i%2==0):
        b.append(a[i])
    else:
        b.appendleft(a[i])
if(n%2==1):
    b.reverse()
for i in b:
    print(i+' ',end="")

Submission status: Accepted

Solution code:
n = int(input())
a=list(map(int, input().split()))
a_copy = a.copy()
b=[]
flg = 0
#print(list(range(n,0,-2)))
for i in range(n-1,0,-2):
  b.append(a[i])
  a_copy.pop(i)
b = b+ a_copy
print(*b)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
ans = []
if n % 2 == 0:
    for i in range(n-1,-1,-2):
        ans.append(a[i])
    for i in range(0,n,2):
        ans.append(a[i])
else:
    for i in range(n-1,-1,-2):
        ans.append(a[i])
    for i in range(1,n,2):
        ans.append(a[i])
print(' '.join(map(str,ans)))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[]
i=n-1
if n==1:
    print(a[0])
    exit()
for _ in range(n//2+1):
    b.append(a[i])
    i-=2
    if i<=-1:
        break
if n%2==0: 
    i=0
else:
    i=1
for _ in range(n//2+1):
    b.append(a[i])
    i+=2
    if i>=n-1:
        break
print(' '.join(map(str,b)))

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

b = []
ki = []
gu = []

for i in range(n):
    if i % 2 == 1:
        ki.append(li[i])
    else:
        gu.append(li[i])

if n %2 == 1:
    gu = gu[::-1]
    print(*(gu+ki))
else:
    ki = ki[::-1]
    print(*(ki+gu))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
#b = []
#for ai in a:
#  b.append(str(ai))
#  b = list(reversed(b))
#print(' '.join(b))
if len(a) % 2 == 0:
  even = []
  odd = []
  for i, ai in enumerate(a):
    if (i + 1) % 2 == 0:
      even.append(str(ai))
    else:
      odd.append(str(ai))

  r = list(reversed(even))
  answer = r + odd
  print(' '.join(answer))
else:
  even = []
  odd = []
  for i, ai in enumerate(a):
    if (i + 1) % 2 == 0:
      even.append(str(ai))
    else:
      odd.append(str(ai))
  r = list(reversed(odd))
  answer = r + even
  print(' '.join(answer))

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 j in range(0,n-1,2):
        b.append(a[j])
    print(*b)
else:
    for i in range(n-1,-1,-2):
        b.append(a[i])
    for j in range(1,n-1,2):
        b.append(a[j])
    print(*b)

Submission status: Accepted

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

liodd = li[::2]
lieven = li[1::2]
if len(lieven) == len(liodd):
  for i in reversed(lieven):
    print(i,end=" ")
  for i in liodd:
    print(i,end=" ")
else:
  for i in reversed(liodd):
    print(i,end=" ")
  for i in lieven:
    print(i,end=" ")

Submission status: Accepted

Solution code:
n = int(input())
a=list(map(int,input().split()))
if n%2:
    for i in a[::2][::-1]:
        print(i,end=' ')
    for i in a[1::2]:
        print(i,end=' ')
    print()
else:
    for i in a[1::2][::-1]:
        print(i,end=' ')
    for i in a[::2]:
        print(i,end=' ')
    print()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
left = []
right = []
if n % 2 == 0:
    for i in range(1,n+1):
        if i % 2 == 0:
            left.append(a[i-1])
        else:
            right.append(a[i-1])
else:
    for i in range(1,n+1):
        if i % 2 != 0:
            left.append(a[i-1])
        else:
            right.append(a[i-1])
left.reverse()
for i in left:
    print(i,end=' ')
for i in right:
    print(i,end=' ')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
alist = list(map(int, input().split()))
b = alist[::-2] + alist[n % 2::2]
print(" ".join(list(map(str, b))))

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline

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

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

print(*ans)

Submission status: Accepted

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

if len(a) % 2 == 1:
  odd = a[1::2]
  even = a[-1::-2]
else:
  odd = a[::2]
  even = a[-1::-2]

for i in even + odd:
  print(i)

Submission status: Accepted

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

if n%2 == 1:
    r = a[::-2]
    l = a[1::2]
else:
    r = a[::-2]
    l = a[::2]
    
print(*r,end=" ")
print(*l)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
for i in range(n-1,-1,-2):
    print(a[i])
if n%2:
    j = 1
else:
    j = 0
for i in range(j,n,2):
    print(a[i])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, collections
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=count=0

ans=collections.deque()
n=int(input())
A=list(map(int,input().split()))
for i in range(n):
    if i%2==0:
        ans.appendleft(A[i])
    else:
        ans.append(A[i])
if n%2==0:
    ans=reversed(ans)
print(*ans)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
n=int(input())
a=input().split()
ans=[]

for i in range(n):
    if n%2==0:
        if i%2==0:
            ans.append(a[i])
    else:
        if i%2!=0:
            ans.append(a[i])
ans=ans[::-1]
for i in range(n):
    if n%2==0:
        if i%2!=0:
            ans.append(a[i])
    else:
        if i%2==0:
            ans.append(a[i]) 
ans=ans[::-1]
ans=' '.join(ans)
if n==1:
    ans=a[0]
'''
for j in range(n):
    ans.insert(0,a[j])
'''
print(ans)

Submission status: Accepted

Solution code:
def examC():
    N = I()
    a = LI()
    v = [i for i in range(N)]
    if N%2==0:
        ans = a[::-2]
        ans.extend(a[0::2])
    else:
        ans = a[-1::-2]
        ans.extend(a[1::2])
    print(" ".join(map(str,ans)))



import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Submission status: Accepted

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

even = [A[i] for i in range(1, n, 2)]
odd = [A[i] for i in range(0, n, 2)]

if n % 2 == 0:
    ans = even[::-1] + odd
else:
    ans = odd[::-1] + even

print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
a1 = a[::2]
a2 = a[1::2]
if n % 2:
  print(*a1[::-1],sep=' ',end=' ')
  print(*a2,sep=' ')
else:
  print(*a2[::-1],sep=' ',end=' ')
  print(*a1,sep=' ')

Submission status: Accepted

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

for i in ans:
    print(str(i) + " ", end = "")

Submission status: Accepted

Solution code:
from collections import deque

n=int(input())
a=list(map(int,input().split()))
res=deque()
if n % 2 == 0:
    for i in range(n // 2):
        res.append(a[i*2])
        res.appendleft(a[i*2+1])
else:
    for i in range(n // 2):
        res.appendleft(a[i*2])
        res.append(a[i*2+1])
    res.appendleft(a[n-1])
print(" ".join(map(str,list(res))))

Submission status: Accepted

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

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

print(' '.join(b))

Submission status: Accepted

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

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

print(*b)