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:
#!/usr/bin/env python3
import sys


def solve_naive(n: int, a: "List[int]"):
    b = list()
    for i in range(n):
        b.append(str(a[i]))
        b.reverse()
    print(" ".join(b))
    return

def solve_(n: int, a: "List[int]"):
    a = list(map(str, a))
    b = list()
    for i in range(n):
        if i % 2 == 0:
            # push
            b.insert(0, a[i])
        else:
            # append
            b.append(a[i])
    if n % 2 == 0:
        b.reverse()
    print(" ".join(b))
    return

def solve__(n: int, a: "List[int]"):
    a = list(map(str, a))
    b = list()
    for i in range(n):
        if i % 2 == (n-1) % 2:
            # push
            b.insert(0, a[i])
        else:
            # append
            b.append(a[i])
    print(" ".join(b))
    return

def solve___(n: int, a: "List[int]"):
    b = list()
    for i in range(n):
        if i % 2 == (n-1) % 2:
            # push
            b.insert(0, a[i])
        else:
            # append
            b.append(a[i])
    print(*b)
    return

def solve(n: int, a: "List[int]"):
    import collections
    b = collections.deque()
    for i in range(n):
        if i % 2 == (n-1) % 2:
            # push
            b.appendleft(a[i])
        else:
            # append
            b.append(a[i])
    print(*b)
    return

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, a)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(n: int, a: "List[int]"):
    if n % 2 == 0:
        b = list(reversed(a[::2]))+a[1::2]
    else:
        b = list(reversed(a[1::2]))+a[::2]
    print(*reversed(b), sep=" ")

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(n)]  # type: "List[int]"
    solve(n, a)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

import collections
import itertools
import sys

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

deq = collections.deque()
n=getint()
vs=getints()

front = True if n % 2 == 0 else False
for d in vs:
    if front:
        deq.append(d)
    else:
        deq.appendleft(d)
    front = not front

res = list(map(lambda s: str(s), deq))

print(" ".join(res))

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 == n % 2:
        j = (n+i)//2
    else:
        j = (n-i)//2
    b[j] = a[i]
print(*b)

Submission status: Accepted

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

for i in range(N):
    if i % 2 == 0:
        ret.append(A[i])
ret.reverse()
for i in range(N):
    if i % 2 == 1:
        ret.append(A[i])

if N % 2 == 0:
    ret.reverse()

print(*ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,*l=map(int,open(0).read().split())
k=l[-1-n%2::-2]+l[::2]
print(*k[::(-1)**n],end=" ")

Submission status: Accepted

Solution code:
from collections import deque


que = deque()
n = int(input())
push_list = list(map(int, input().split()))
for i in range(len(push_list)):
    if not i % 2:
        que.append(push_list[i])
    else:
        que.appendleft(push_list[i])
        


if  n % 2:
    que.reverse()
    
    
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(n):
    ai = a[i]
    if i%2 == 0:
      b.append(ai)
    else:
      b.appendleft(ai)
else:
  for i in range(n):
    ai = a[i]
    if i%2 == 0:
      b.appendleft(ai)
    else:
      b.append(ai)
print(' '.join(map(str, b)))

Submission status: Accepted

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

lstb = [0]*n

mid = n//2
if n % 2 == 0:
    for i in range(n):
        if i%2 == 0:
            lstb[mid + i//2] = lst[i]
        else:
            lstb[mid - i//2 - 1] = lst[i]
else:
    for i in range(n):
        if i==0:
            lstb[mid] = lst[i]
        elif i%2 == 0:
            lstb[mid - i//2] = lst[i]
        else:
            lstb[mid + i//2 + 1] = lst[i]

ans = ''
for i in range(n):
    ans += str(lstb[i])+' '
print(ans[:-1])

Submission status: Accepted

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

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 i % 2 != 0:
        d.append(a[i])
    else:
        d.appendleft(a[i])

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

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[n//2+i//2] = a[i]
    else:
        b[n//2-i//2-1] = a[i]

if n % 2 == 1:
    print(*b[::-1])
else:
    print(*b)

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[n//2+i//2] = a[i]
    else:
        b[n//2-i//2-1] = a[i]
        
if n % 2 == 1:
    b = b[::-1]

if len(b) == 1:
    print(b[0])

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

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 i % 2 != 0:
        d.append(a[i])
    else:
        d.appendleft(a[i])

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(n: int, a: "List[int]"):
    r = [str(rr) for rr in list(reversed(a[::2]))]
    l = [str(rr) for rr in a[1::2]]
    if n % 2 == 1:
        print(' '.join(r + l))
    else:
        print(' '.join(list(reversed(r+l))))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, a)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
an = list(map(int,input().split()))
an.reverse()
b = [0] * n
for i,v in enumerate(an):
    if i%2==0:
        b[i//2]=v
    else:
        b[n-i//2-1]=v
print(" ".join(map(str,b)))

Submission status: Accepted

Solution code:
def f(n):
    l = []
    for i in range(n):
        l.append(i)
        l = l[::-1]
    return l

def index(N):
    if N % 2 == 0:
        L = list(range(1, N, 2)[::-1])
        L.extend(range(0, N, 2))
    else:
        L = list(range(2, N, 2)[::-1])
        L.append(0)
        L.extend(range(1, N-1, 2))
    return L

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

    print(*[A[i] for i in index(N)])
main()

Submission status: Accepted

Solution code:
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(0, n, 2):
        print(a[i], end=' ')
    
elif 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=' ')

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 i % 2 == 0:
        D.append(A[i])
    else:
        D.appendleft(A[i])
if i % 2 == 0:
    D.reverse()
print(*D)

Submission status: Accepted

Solution code:
N = int(input())
nums = list(input().split())
odd = []
even = []
for idx, num in enumerate(nums):
  if idx%2 == 0:
    even.append(num)
  else:
    odd.append(num)
if N%2 == 0:
  print(' '.join(odd[::-1]+even))
else:
  print(' '.join(even[::-1]+odd))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    
    b = [0 for _ in range(N)]
    base = (N//2)
    cnt = 1
    
    flg = False
    if N % 2 == 0:
        flg = True
    
    for i, val in enumerate(A):
        
        if flg == True:
            if i == 0:
                b[base] = val
            elif i % 2 == 1:
                b[base-cnt] = val
            else:
                b[base+cnt] = val
                cnt+=1
        else:
            if i == 0:
                b[base] = val
            elif i % 2 == 1:
                b[base+cnt] = val
            else:
                b[base-cnt] = val
                cnt+=1
    
    print(*b)
    
        
if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def main(n,A):
    B = []
    if n%2==1:
        for i in range(n-1,-1,-2):
            B.append(A[i])
        for i in range(1,n-1,2):
            B.append(A[i])
    else:
        for i in range(n-1,0,-2):
            B.append(A[i])
        for i in range(0,n-1,2):
            B.append(A[i])
        
    print(" ".join(B))
    
if __name__ == '__main__':
    n = int(input())
    A = [str(a) for a in input().split()]
    main(n,A)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
# -*- coding: UTF-8 -*-
# ABC066_C

N = int(input())
tmp = input()
list = []
list = tmp.split()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

N = int(input())
A = list(map(int, input().split()))
B = deque([])

for i, a in enumerate(A):
    if i % 2 == 0:
        B.append(a)
    else:
        B.appendleft(a)

C = list(B)
if N % 2 == 1:
    C = C[::-1]

for c in C:
    print(c, end=' ')
print()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
n=int(input())
a_list=list(map(int,input().split()))
if n%2==0:
    c=n//2
    x=n
    for i in range(c):
        print(a_list[x-1],end='')
        print(' ',end='')
        x-=2
    x=1
    for i in range(c):
        print(a_list[x-1],end='')
        print(' ',end='')
        x+=2
else:
    c=n//2
    x=n
    for i in range(c+1):
        print(a_list[x-1],end='')
        print(' ',end='')
        x-=2
    x=2
    for i in range(c):
        print(a_list[x-1],end='')
        print(' ',end='')
        x+=2

Submission status: Accepted

Solution code:
from collections import deque
def main():
    n = int(input())
    a = [0] + list(map(int, input().split()))
    b = deque(maxlen=n+1)
    for i in range(1,n+1):
        if (i % 2 == 0 and n % 2 == 0 ) or (i % 2 != 0 and n % 2 != 0 ):
            b.appendleft(a[i])
        else:
            b.append(a[i])

    print(*b)

main()

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
odd, even = [],[]
for i in range(n):
  if i%2 == 1:
    odd.append(a[i])
  else:
    even.append(a[i])

if n%2 == 0:
  odd.reverse()
  b = odd+even
else:
  even.reverse()
  b = even+odd
print(" ".join(map(str,b)))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    print(min(a+b,b+c,c+a))
    return

#B
def B():
    def check(s):
        x = len(s)
        if x % 2:
            return False
        if s[:x // 2] == s[x // 2:]:
            return True
    s = S()
    for i in range(1,len(s)):
        if check(s[: - i]):
            print(len(s) - i)
            return

#C
def C():
    II()
    a = LI()
    ans1 = a[-1::-2]
    ans2 = a[-2::-2][::-1]
    ans = ans1 + ans2
    print(*ans)
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Accepted

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

b1=[]
b2=[]
offset=0
if n%2==1:
    offset=1
for i in range(n):
    if (i+offset)%2==0:
        b1.append(a[i])
    else:
        b2.append(a[i])
b2=list(reversed(b2))
b=b2+b1
for i in b:
    print(i,end=" ")

Submission status: Accepted

Solution code:
n=int(input())
a_L=list(input().split())
ans1=[]
ans2=[]

if n==1:
	print(a_L[0])
else:
	for i in range(0,n,2):
		ans2.append(a_L[i])
	for i in range(1,n,2):
		ans1.append(a_L[i])


if n%2==0:
	ans1.reverse()
	print(*(ans1+ans2))
else:
	ans2.reverse()
	print(*(ans2+ans1))

Submission status: Accepted

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

else:
  print(*[ans][0])

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
a = [int(i) for i in input().split()]
d = deque()
for i, v in enumerate(a):
    if i % 2: d.append(v)
    else: d.appendleft(v)
print(*d if n % 2 else reversed(d))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

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

from collections import deque

ans = deque()

x = 1
for i in a:
    if x: ans.append(i)
    else: ans.appendleft(i)
    x^=1

if x: print(*ans)
else: print(*(reversed(ans)))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#ABC66 C

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

front = []
back = []

for i in range(n):
    if i % 2 == 0:
        front.append(a[i])
    else:
        back.append(a[i])
if n % 2 == 1:
    front = front[::-1]
    ans = front+back
    print(' '.join(map(str,ans)))
else:
    back = back[::-1]
    ans = back+front
    print(' '.join(map(str,ans)))

Submission status: Accepted

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

b = [0] * n


if n % 2 == 1:
    for i in reversed(range(n)):
        if i % 2 == 1:
            b[n // 2 + int(i/2 + 0.9)] = a[i]
        else:
            b[n // 2 - int(i/2 + 0.9)] = a[i]
else:
    for i in reversed(range(n)):
        if i % 2 == 1:
            b[n // 2 - 1 + int(i/2 + 0.9)] = a[i]
        else:
            b[n // 2 - 1 - int(i/2 + 0.9)] = a[i]


if n % 2 == 1:
    for i in b:
        print(i, end=" ")
else:
    for i in reversed(b):
        print(i, end=" ")

Submission status: Accepted

Solution code:
BIGMOD = 10**9+7

def modPow(x,n):
    ans = 1
    while n >= 1:
        if bin( n & 1)==bin(1):
            ans = (ans*x) % BIGMOD
        x = x * x % BIGMOD
        n = n>>1
    return ans % BIGMOD

def modFact(N):
    fact = []
    fact.append(1) #0! = 1
    for i in range(1,N+1):
        a = fact[i-1]*i % BIGMOD
        fact.append(a)
    return fact

def modInvFact(fact):
    invFact = []
    for i in range(1,N+2):
        a = modPow(fact[i-1],BIGMOD-2)
        invFact.append(a)
    return invFact

def modPlus(a,b):
    return (a + b) % BIGMOD

def modMinus(a,b):
    if a-b >= 0:
        return (a - b) % BIGMOD
    else:
        return (a - b + BIGMOD)
    
def modMulti(a,b):
    return a * b % BIGMOD

# fact(n),invFact(r),invFact(n-r)
def nCr(fact,invFact,n,r):
    return (fact[n] * invFact[r] * invFact[n-r] ) %BIGMOD

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

odda = []
evena = []
for i in range(n):
    if i%2 == 0:
        odda.append(a[i])
    else:
        evena.append(a[i])
ans = []
if n%2 == 0:
    evena.reverse()
    for i in range(len(evena)):
        ans.append(evena[i])
    for i in range(len(odda)):
        ans.append(odda[i])
else:
    odda.reverse()
    for i in range(len(odda)):
        ans.append(odda[i])
    for i in range(len(evena)):
        ans.append(evena[i])

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

Submission status: Accepted

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

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())
s=list(input().split())
b=s[N::-2]+s[N%2::2]
print(*(b))

Submission status: Accepted

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

for i in [i for i in range(n) if i%2 == n%2]:
     ans += [a[i]]

print(*ans)

Submission status: Accepted

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

    for i in [i for i in range(n) if i%2 == 0]:
         ans += [a[i]]

if n % 2 == 1:
    for i in [i for i in range(n) if i%2 == 0][::-1]:
         ans += [a[i]]

    for i in [i for i in range(n) if i%2 == 1]:
         ans += [a[i]]

print(*ans)

Submission status: Accepted

Solution code:
from collections import deque

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

que=deque()

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

Submission status: Accepted

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

even,odd=[],[]

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

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    A = 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]))


main()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    A = input().split()
    B = [0] * n
    k = n % 2
    l = n // 2
    if k == 0:
        l -= 1
    r = l + 1
    for i in range(n):
        if i % 2 != k:
            B[l] = A[i]
            l -= 1
        else:
            B[r] = A[i]
            r += 1
    print(' '.join(B))


main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

key = len(A) % 2
ans = [0]*N
mid = (len(A)) // 2
for i in range(N):
    ans[mid + ((-1)**(i+key))*((i+1)//2)] = A[i]
for i in range(N):
    print(ans[i], end = " ")
print("")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
n=int(input())
A=list(input().split())
B=deque([])
if n%2==0:
    for i in range(n//2):
        B.append(A[i*2])
        B.appendleft(A[i*2+1])
    print(" ".join(B))
else:
    for j in range((n-1)//2):
        B.append(A[j*2])
        B.appendleft(A[j*2+1])
    B.append(A[n-1])
    B.reverse()
    print(" ".join(B))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(n: int, a: "List[int]"):
    from collections import deque

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

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

    d = map(str, d)
    print(' '.join(d))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, a)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""
1 2 3 4 5 6 7

1

1 2
2 1

2 1 3
3 1 2

3 1 2 4
4 2 1 3

4 2 1 3 5
5 3 1 2 4

5 3 1 2 4 6
6 4 2 1 3 5

6 4 2 1 3 5 7
7 5 3 1 2 4 6
"""

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

Submission status: Accepted

Solution code:


def main():
    num = int(input())
    data = list(map(int, input().split()))
    a = data[0::2]
    b = data[1::2]
    if num % 2 == 0:
        ans = b[::-1] + a
    else:
        ans = a[::-1] + b
    print(' '.join(list(map(str, ans))))




if __name__ == '__main__':
    main()

Submission status: Accepted

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

# B = [0 for i in range(N)]
med = N // 2
B = ['0' for i in range(N)]
fo = []
# for i in range(med, N):
#     fo.append
if N % 2 == 0:
    f_c = med
    for i in range(0, N, 2):
        B[f_c] = A[i]
        f_c += 1

    # print(f_c)
    # print(B)
    B = B[::-1]
    f_c = med
    for i in range(1, N, 2):
        B[f_c] = A[i]
        f_c += 1

    B = B[::-1]
    # print(B)
    print(' '.join(B))

else:
    B[med] = A[0]
    f_c = med+1
    for i in range(1, N, 2):
        B[f_c] = A[i]
        f_c += 1
    # print(B)
    B = B[::-1]
    # print(B)
    f_c = med
    for i in range(0, N, 2):
        B[f_c] = A[i]
        f_c += 1

    B = B[::-1]
    print(' '.join(B))

Submission status: Accepted

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

else:
    for i in range(n//2):
        lss.append(a[2*i+1])
    for i in range(n//2+1):
        lse.append(a[n-2*i-1])


ls = lse+lss

print(" ".join(ls))

Submission status: Accepted

Solution code:
n = int(input())
A = [int(i) for i in input().split()]
center = n//2
ans = [0 for i in range(n)]
haba = 1
hugou = n%2 == 1

for a in A:
    ans[center] = a
    if hugou:
        center += haba
    else:
        center -= haba
    haba += 1
    hugou = not(hugou)
for i in ans[:-1]:
    print(i,end = " ")
print(ans[-1])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import deque

N = int(input())
*A, = map(int, input().split())
B = deque([])
for i, a in enumerate(A):
    if i % 2 == 0:
        B.append(a)
    else:
        B.appendleft(a)
if N % 2 == 1:
    B.reverse()
print(*B)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(n: int, a: "List[int]"):
    ret = []
    if n % 2 == 0:
        for i in range(n - 1, 0, -2):
            ret.append(a[i])
        for i in range(0, n - 1, 2):
            ret.append(a[i])
    else:
        for i in range(n - 1, -1, -2):
            ret.append(a[i])
        for i in range(1, n - 1, 2):
            ret.append(a[i])
    print(' '.join([str(r) for r in ret]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, a)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
i=N-1
while(i>=0):
    print(A[i],end=" ")
    i-=2
if i==-2:
    i=1
else:
    i=0
while(i<N):
    print(A[i],end=" ")
    i+=2
print()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    a = A
    even = [n for i, n in enumerate(a) if i % 2 == 0]
    odd = [n for i, n in enumerate(a) if i % 2 != 0]

    l = len(a)
    if l % 2 != 0:
        even.reverse()
        ans = even + odd
    else:
        odd.reverse()
        ans = odd + even
    print(*ans)

if __name__ == '__main__':
    main()