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

ans=[]
if n%2==0:
    num=n+2
    for i in range(n):
        if num==2:
            num=1
            ans.append(a[0])
        elif num%2==0:
            num-=2
            ans.append(a[num-1])
        else:
            num+=2
            ans.append(a[num-1])
else:
    num=n
    for i in range(n):
        if num==1:
            ans.append(a[0])
            num=2
        elif num%2!=0:
            ans.append(a[num-1])
            num-=2
        else:
            ans.append(a[num-1])
            num+=2
print(*ans)

Submission status: Accepted

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n=int(input())
	s = list(IN())
	s_odd=s[1::2]
	s_even=s[::2]
	if len(s)%2==1:
		s_even=s_even[::-1]
		ret = s_even+s_odd
	else:
		s_odd=s_odd[::-1]
		ret = s_odd+s_even
	print(*ret)
	
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

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

    reverse = False
    for i in range(n):
        if not reverse:
            d.append(A[i])
            reverse = not reverse
        else:
            d.appendleft(A[i])
            reverse = not reverse

    if not reverse:
        for i in d:
            print(i, end=' ')
    else:
        for i in reversed(d):
            print(i, end=' ')


resolve()

Submission status: Accepted

Solution code:
n=int(input())

t = list(map(int,input().split()))

mae = []
naka = [t[0]]
usiro = []

for i in range(1,n):
    if i%2==1:
        mae.append(t[i])
    else:
        usiro.append(t[i])

if n%2==0:
    mae.reverse()
    ans = mae+naka+usiro
else:
    usiro.reverse()
    ans = usiro+naka+mae
print(' '.join(map(str,ans)))

Submission status: Accepted

Solution code:
input()
from collections import *
d=deque()
s=1
for i in map(int,input().split()):
  if s>0: d.append(i)
  else: d.appendleft(i)
  s*=-1
print(*list(d)[::s])

Submission status: Accepted

Solution code:
N = int(input())
Ai = input().split()
if N != 1:
  if N%2==0:
    b = Ai[::-2] + Ai[::2]
  else:
    b = Ai[-2::-2] + Ai[::2]
    b = b[::-1]
else:
  b = Ai
print(*[bb for bb in b], sep=" ")

Submission status: Accepted

Solution code:
n=int(input());l=input().split();print(*l[::-2]+l[n%2::2])

Submission status: Accepted

Solution code:
n=int(input());l=list(input().split());print(*l[n-n%2::-2]+l[n%2::2])

Submission status: Accepted

Solution code:
b=int(input())%2
from collections import deque
d=deque()
for e,i in enumerate(map(int,input().split())):
  if e%2: d.append(i)
  else: d.appendleft(i)
print(*list(d)[::b*2-1])

Submission status: Accepted

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

if n%2==0:
    odd = list(range(1, n, 2))
    eve = list(reversed(list(range(2, n+1, 2))))
    ix = eve+odd
    for i in ix:
        print(a[i-1], end=' ')

else:
    odd = list(reversed(list(range(1, n+1, 2))))
    eve = list(range(2, n, 2))
    ix = odd+eve
    for i in ix:
        print(a[i-1], end=' ')

print()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

from collections import deque

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.reverse()
	print(*b)
else:
	print(*b)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
a1 = []
a2 = []
for i in range(n):
    if i % 2 == 0:
        a1.append(a[i])
    else:
        a2.append(a[i])
if n % 2 == 0:
    a2.reverse()
    print(*a2+a1)
else:
    a1.reverse()
    print(*a1+a2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

ans = A[N-1::-2] + A[N%2::2]

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

Submission status: Accepted

Solution code:
from collections import deque

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

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

print(' '.join(map(str, b))) if n % 2 == 0 else print(' '.join(map(str, reversed(b))))

Submission status: Accepted

Solution code:
from collections import deque


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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

odd, even = [], []

for i in range(n):
    if (i + 1) % 2 ==1:
        odd += [l[i]]
    else:
        even += [l[i]]

even.reverse()
e_o = even + odd

if n % 2 == 1:
    e_o.reverse()
    print(*e_o)
else:
    print(*e_o)

Submission status: Accepted

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

left = []
right = []

for i in range(n):
    if i % 2 == 0:
        right.append(al[i])
    else:
        left.append(al[i])

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

print(*ans, sep=' ')

Submission status: Accepted

Solution code:
N, *A = map(int, open(0).read().split())

od = A[::2]
ev = A[1::2]

if N & 1:
  ans = od[::-1]+ev
else:
  ans = ev[::-1]+od
  
print(" ".join([str(a) for a in ans]))

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
a = [int(x) for x in input().split()]
b = deque()

rev = False

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

if rev:
    print(*list(b)[::-1])
else:
    print(*list(b))

Submission status: Accepted

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

if len(a)%2 == 0:
    for i in range(len(a)//2):
        b.append(ar[i*2])
        c.append(a[i*2])
else:
    for i in range(-(-(len(a))//2)):
        if i == len(a)//2:
            b.append(ar[(i*2)])
        else:
            b.append(ar[i*2])
            c.append(a[(i*2)+1])

print(' '.join(map(str, b+c)))

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:
        b.appendleft(a[i])
    else:
        b.append(a[i])

if n&1:
    b = list(b)[::-1]
    print(*b)
else:
    print(*b)

Submission status: Accepted

Solution code:
N = int(input())
points = list(map(int, input().split()))
even_points = [points[index] for index in range(len(points)) if index % 2 == 0]
odd_points = [points[index] for index in range(len(points)) if index % 2 == 1]

if N % 2 == 0:
  odd_points = list(reversed(odd_points))
  odd_points.extend(even_points)
  ans = odd_points
else:
  even_points = list(reversed(even_points))
  even_points.extend(odd_points)
  ans = even_points

ans = list(map(str, ans))
print(' '.join(ans))

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
a = [int(x) for x in input().split()]
d = deque()
is_rev = False
for i in a:
    if is_rev:
        d.appendleft(i)
    else:
        d.append(i)
    is_rev = not is_rev
if is_rev:
    d = list(d)[::-1]
print(*d)

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
aa = list(map(int, input().split()))
bb = deque()
left = True
for a in aa:
    if left:
        bb.append(a)
    else:
        bb.appendleft(a)
    left = not left

if not left:
    bb.reverse()
print(*list(bb))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=deque(limii())
b=deque([])
for i in range(n):
    if i%2==1:
        x=arr.popleft()
        b.appendleft(str(x))

    else:
        x=arr.popleft()
        b.append(str(x))
if n%2==0:
    print(" ".join(list(b)))
else:
    print(" ".join(list(reversed(list(b)))))

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
b = [-1 for i in range(n)]
if n%2==1:#odd
  left = n//2+1
  right = left - 2
  center = left - 1
  b[center] = a[0]
  
  for i in range(1,n):
    if i%2==1:#odd is left
      b[left]=a[i]
      left+=1
    else:#even is right
      b[right]=a[i]
      right-=1
          
else:#even
  left = n//2
  right = left-1
  for i in range(n):
    if i%2==1:
      b[right]=a[i]
      right-=1
    else:
      b[left]=a[i]
      left+=1
    
ans=""
for i in range(n):
  ans+=str(b[i])+" "
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+n)%2!=0:
        b.appendleft(a[i])
    else:
        b.append(a[i])
print(*b)

Submission status: Accepted

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

Submission status: Accepted

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

print(' '.join(map(str, tmp)))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
left = []
right = []
for i in range(n):
  right.append(str(a[i]))
  left,right = right,left
left.reverse()
print(" ".join(left+right))

Submission status: Accepted

Solution code:
import os
import sys
from collections import deque

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

que = deque()
for i in range(N):
    if i % 2 == 0:
        que.append(A[i])
    else:
        que.appendleft(A[i])
if N % 2:
    que.reverse()
print(*que)

Submission status: Accepted

Solution code:
n = int(input())
a = input().split()
b = []
for i in range(n - 1, -1, -2):
  b.extend([a[i]])
for j in range(n % 2, n, 2):
  b.extend([a[j]])
print(" ".join(b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=input().split()
numbers=[b for b in a]
n=len(numbers)
if n%2==0:
    kisuu=numbers[1::2]
    guusuu=numbers[0::2]
    kisuu.reverse()
    kotae=kisuu+guusuu
else:
    kisuu=numbers[1::2]
    guusuu=numbers[0::2]
    guusuu.reverse()
    kotae=guusuu+kisuu
answer=''
for z in kotae:
    answer+=str(z)
    answer+=' '
print(answer)

Submission status: Accepted

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

for i in range(n):
    if (i + 1) % 2 == 0:
        ans.appendleft(s[i])
    else:
        ans.append(s[i])
if n % 2 == 1:
    ans.reverse()
ans = map(str, ans)
print(' '.join(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
s1 = []
s2 = []
for i in range(n):
  if i % 2 == 0:
    s1.append(a[i])
  else:
    s2.append(a[i])

if n % 2 == 0:
  for x in list(reversed(s2)) + s1:
    print(x, end=' ')
else:
  for x in list(reversed(s1)) + s2:
    print(x, end=' ')
print()

Submission status: Accepted

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

top = []
last = []
for i in range(n):
  if i % 2 == 0:
    top.append(a[i])
  else:
    last.append(a[i])
    
top.extend(reversed(last))

print(' '.join(top))

Submission status: Accepted

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

b = A[::2][::-1] + A[1::2]
if N % 2 == 0:
    b = b[::-1]
print(" ".join(b))

Submission status: Accepted

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

    deq = deque()
    for i in range(n):
        if i % 2 == 0:
            deq.append(a[i])
        else:
            deq.appendleft(a[i])
    
    ans = list(deq)
    if n % 2 == 0:
        print(*ans, sep=' ')
    else:
        print(*ans[::-1], sep=' ')

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

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 == 0:
        q.append(a[i])
    else:
        q.appendleft(a[i])
if n % 2 ==0:
    print(*list(q))
else:
    print(*list(q)[::-1])

Submission status: Accepted

Solution code:
from collections import deque
n=int(input())
a=list(map(int,input().split()))
rflag=0
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.reverse()
print(*list(b),sep=" ")

Submission status: Accepted

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

bl = [a[-2*i-1-n%2] for i in range(n//2)]
br = [a[2*i] for i in range((n+1)//2)]
b = bl + br
if n%2 == 0 :
    print(*b, sep=" ")
else :
    print(*b[::-1], sep=" ")

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
print(*A[::-2],end=' ')
print(*A[N%2::2])

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])
if len(B) > len(C):
    ans = list(reversed(B)) + C
    print(*ans)
else:
    ans = list(reversed(C)) + B
    print(*ans)

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.appendleft(a[i])
        else:
            b.append(a[i])
else:
    for j in range(n):
        if j % 2 == 0:  # 偶数なら後ろ
            b.appendleft(a[j])
        else:
            b.append(a[j])

print(*b)

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 ii in range(0, n, 2):
        b.append(a[ii])

else:
    for j in range(n-1, -1, -2):
        b.append(a[j])

    for jj in range(1, n, 2):
        b.append(a[jj])

print(*b)

Submission status: Accepted

Solution code:
def main():
  n = int(input())
  a = list(input_list_str())
  index = n - 1
  ans = [a[index]]
  
  is_add = False
  for i in range(n-1):
    if is_add:
      index += 2
    else:
      index -= 2
    if index < 0:
      index = 0
      is_add = True
      
    ans.append(a[index])
    
    if index == 0 and is_add is False:
      index = -1
      is_add = True
    
      
  print(' '.join(ans))


def input_list():
  return map(int, input().split())

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

import math
import fractions
from functools import reduce
main()

Submission status: Accepted

Solution code:
from collections import deque

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

ans = deque()

if n %2 == 0:
    for i in range(0,n):
        if i %2 != 0:
            ans.appendleft(a_L[i])
        else:
            ans.append(a_L[i])
else:
    for i in range(0,n):
        if i %2 == 0:
            ans.appendleft(a_L[i])
        else:
            ans.append(a_L[i])

print(*ans)

Submission status: Accepted

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

from collections import deque

ans = deque()

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

for i in range(N):
    print(ans[i],end=" ")

Submission status: Accepted

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

from collections import deque

def main():
    mod=10**9+7
    N=I()
    a=LI()
    ans=deque()
    for i in range(N):
        if i%2==1:
            ans.append(a[i])
        else:
            ans.appendleft(a[i])
    if N%2==0:
        ans.reverse()
    print(' '.join(map(str, ans)))
    

main()

Submission status: Accepted

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

if n % 2 == 1:
    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, -1, -2):
        print(a[i], end=" ")
    for i in range(0, n, 2):
        print(a[i], end=" ")

Submission status: Accepted

Solution code:
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import deque


n = int(input().strip())
a_list = [int(i) for i in input().rstrip().split()]
#-----

dq = deque()

flag=1
for i in a_list:
    if flag == 1:
        dq.append(i)
    else:
        dq.appendleft(i)
    
    flag *= -1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

from collections import deque
b=deque()
for i in range(n):
    if n%2==i%2:
        b.append(a[i])
    else:
        b.appendleft(a[i])
print(*b)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(_) for _ in input().split()]
left = [0] * (n//2)
right = [0] * (n//2)
if n % 2 == 0:
    left = a[n:0:-2]
    right = a[0:n:2]
    ans = left + right
else:
    left  = a[n:1:-2]
    right = a[1:n:2]
    ans = left + [a[0]] + right
for i in ans:
    print(i, end=" ")

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
n=int(input())
a=deque([int(i) for i in input().split()])
b=deque()

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

if n % 2 == 0:
    s = " ".join(list(reversed(C)))
    t = " ".join(B)
    print(s + " " + t)
else:
    s = " ".join(list(reversed(B)))
    t = " ".join(C)
    print(s + " " + t)

Submission status: Accepted

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

Submission status: Accepted

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

from collections import deque
q=deque()
q.append(a[0])
for i in range(1,n):
    if i%2==1:
        q.append(a[i])
    else:
        q.appendleft(a[i])
if n%2==0:
    print(*list(q)[::-1])
else:
    print(*q)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC066c
from collections import deque
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


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

Submission status: Accepted

Solution code:
def main():
    length = int(input())
    numbers = list(map(int, input().split()))
    answer = [0] * length
    if length % 2:
        answer[:length // 2 + 1] = numbers[::-2]
        answer[length // 2 + 1:] = numbers[1::2]
    else:
        answer[:length // 2] = numbers[::-2]
        answer[length // 2:] = numbers[::2]
    print(" ".join(list(map(str, answer))))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=a[::-1] #逆順

ans=[]

if len(a)%2==0: #偶数の場合
    for i in range(0,n,2):
        ans.append(b[i])
    for i in range(0,n,2):
        ans.append(a[i])
else: #奇数の場合
    for i in range(0,n,2):
        ans.append(b[i])
    for i in range(1,n,2):
        ans.append(a[i])
print(*ans)

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
lis = list(input().split())
ans = deque([])
x = n % 2
for i in lis:
    
    if x % 2 == 0:
        ans.append(i)
    else:
        ans.appendleft(i)
    x += 1
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==0):
        b.append(a[i])
    else:
        b.appendleft(a[i])

for i in range(n) if n%2==0 else (reversed(range(n))):
    print(b[i],end=' ')