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:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()

    b = [0] * n

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

        for i in b:
            print(i, end=' ')
    else:
        k = n//2+1
        for i in range(k):
            b[i] = a[n - i * 2-1]

        for i in range(k-1):
            b[k+i] = a[(i+1)*2-1]

        for i in b:
            print(i, end=' ')


solve()

Submission status: Accepted

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

odd = []
even = []

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

if n%2 == 0:
    odd.reverse()
    order = odd + even
else:
    even.reverse()
    order = even + odd

b = []
for i in order:
    b.append(a[i])
print(*b, sep=' ')

Submission status: Accepted

Solution code:
n = int(input())
a = input().split()
even = a[::2]
odd =a [1::2]

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

print(' '.join(b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n = int(input())
a = list(map(int, input().split()))
res = [-1]*n
last = n-1
middle = math.ceil(n/2)
for i in range(middle):
    res[i] = str(a[last - 2*i])

for i in range(n//2):
    res[middle+i] = str(a[last - 2*(n//2)+i*2 + 1])
print(" ".join(res))

Submission status: Accepted

Solution code:
import sys
from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
odds, evens = A[0::2], A[1::2]
if N % 2 == 0:
    evens = evens[::-1]
    print(' '.join(str(x) for x in evens+odds))
else:
    odds = odds[::-1]
    print(' '.join(str(x) for x in odds+evens))

Submission status: Accepted

Solution code:
import collections

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

B = list(B) if n % 2 == 0 else list(B)[::-1]
print(' '.join(map(str, B)))

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    a = list(int(_) for _ in input().split())
    b = []
    for i in range(N):
        if((N-1)-i*2>0):
            b.append(a[(N-1)-i*2])
        else:
            b.append(a[max(0,i*2-N)])
    print(' '.join(str(_) for _ in b))
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

import collections

b = collections.deque()

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

print(*b)

Submission status: Accepted

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

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:
  b.reverse()
  
print(" ".join(b))

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True, end=" ")

N=_I()
A=LI()


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

Submission status: Accepted

Solution code:
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n = ni()
a = collections.deque(nl())
ans = collections.deque()
if n % 2 == 0:
    for i in range(n):
        if i % 2 == 0:
            ans.append(str(a.popleft()))
        else:
            ans.appendleft(str(a.popleft()))
else:
    for i in range(n):
        if i % 2 == 0:
            ans.appendleft(str(a.popleft()))
        else:
            ans.append(str(a.popleft()))
print(' '.join(ans))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
fastinput=sys.stdin.readline
from collections import deque
N=int(input())
a=[int(i) for i in fastinput().split()]
result=deque()
for k,i in enumerate(a):
    if (N-k)%2:
        result.appendleft(i)
    else:result.append(i)
print(" ".join([str(i) for i in result]))

Submission status: Accepted

Solution code:
import sys
fastinput=sys.stdin.readline
from collections import deque
N=int(input())
a=fastinput().split()
result=deque()
for k,i in enumerate(a):
    if (N-k)%2:
        result.appendleft(i)
    else:result.append(i)
print(" ".join(result))

Submission status: Accepted

Solution code:
import sys
fastinput=sys.stdin.readline
N=int(input())
a=[int(i) for i in fastinput().split()]
result=[None]*N
if N%2:#odd
    c=(N-1)//2
    for num,i in enumerate(a):
        r=(num+1)//2
        if num==0:
            result[c]=i
        else:
            if num%2:#右半分
                result[c+r]=i
            else:
                result[c-r]=i
else:#even
    for num,i in enumerate(a):
        d=(N-num-1)//2
        if num%2:#左半分
            result[d]=i
        else:
            result[N-1-d]=i
print(" ".join([str(j) for j in result]))

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 n%2!=i%2:
        q.appendleft(A[i])
    else:
        q.append(A[i])

#print(q)
l=list(q)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
e = [a[i] for i in range(n) if i % 2 == 1]
o = [a[i] for i in range(n) if i % 2 == 0]
if (n % 2 == 1):
    ans = o[::-1] + e
else:
    ans = e[::-1] + o
ans = [str(i) for i in ans]
ans = " ".join(ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
count = 0
i = 0
j = -1
k = -1

for _ in range(n):
  if count % 2 == 0:
    b[i] = a[k]
    i += 1
    k -= 1
  else:
    b[j] = a[k]
    j -= 1
    k -= 1
  count += 1

print(*b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import deque

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

ans = deque()

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

if(len(a) % 2 != 0):
    ans.reverse()

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

Submission status: Accepted

Solution code:
import sys

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

odd = a[1::2]
even = a[0::2]
odd.reverse()
ans = odd+even

if(len(a) % 2 != 0):
    ans.reverse()

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

Submission status: Accepted

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

B = []
if(n%2 == 1):
  p = n//2
  B.append(str(A[2*p]))
  for i in range(p):
   B.append(str(A[2*(p-1-i)]))
  for i in range(p):
    B.append(str(A[2*i+1]))

elif(n%2 == 0):
  p = n//2 
  for i in range(p):
   B.append(str(A[2*(p-1-i)+1]))
  for i in range(p):
    B.append(str(A[2*i]))

b = ' '.join(B) 
print(b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(str, input().split()))

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

    if len(A) % 2 == 0:
        return ' '.join(even[::-1] + odd)
    else:
        return ' '.join(odd[::-1] + even)


if __name__ == '__main__':
    print(main())

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


ans = list(map(str,b))
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, a in enumerate(A):
    if i % 2 == 0:
        B.appendleft(a)
    else:
        B.append(a)

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

B = list(map(str, list(B)))

print(" ".join(B))

Submission status: Accepted

Solution code:
N = int(input())
alist = list(input().split())
if N % 2 == 0:
    a1 = alist[1::2]
    a2 = alist[0::2]
    a1.reverse()
    a1.extend(a2)
else:
    a1 = alist[0::2]
    a2 = alist[1::2]
    a1.reverse()
    a1.extend(a2)
c = ' '.join(a1)
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
# 1
# 21
# 312
# 4213
# 53124
if n == 1:
    print(a[0])
    exit()
#a.sort()
if n % 2 == 0:
    for i in reversed(range(n // 2)):
        print(a[2 * i + 1], end=" ")
    for j in range(n // 2):
        print(a[2 * j], end=" ")
else:
    for i in reversed(range(n // 2 + 1)):
        print(a[2 * i], end=" ")
    for j in range(n // 2):
        print(a[2 * j + 1], end=" ")

Submission status: Accepted

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

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

ans = " ".join(ans)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
A=input().split()
print(' '.join(A[(n+1)%2::2][::-1]+A[n%2::2]))

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=' ' )
else:
    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()))
X = deque([str(A[0])])
append_ = True if n % 2 != 0 else False
for a in A[1:]:
    if append_:
        X.append(str(a))
    else:
        X.appendleft(str(a))
    append_ = not append_
print(" ".join(X))

Submission status: Accepted

Solution code:
def pushpush(N: int, A: list)->list:
    b = []
    for i, a in enumerate(reversed(A)):
        if i % 2 == 0:
            b.append(a)
    for i, a in enumerate(A):
        if i % 2 == N % 2:
            b.append(a)
    return b


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = pushpush(N, A)
    print(' '.join(map(str, ans)))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for num in nums:
    print(num, '', end='')

Submission status: Accepted

Solution code:
input();a=input().split();print(' '.join(a[::-2]+a[len(a)%2::2]))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = []
if n % 2 == 0:
    for i in range(n-1,0,-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([str(i) for i in 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.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:
from collections import deque
n=int(input())
a=[int(i) for i in input().split()]
ans=deque([])
for i,j in enumerate(a):
    if n%2==i%2:
        ans.append(j)
    else:
        ans.appendleft(j)
print(*ans,sep=' ')

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
mod2 = n % 2
a = list(map(int, input().split()))
ans = deque()
for key,value in enumerate(a):
  if mod2 == key % 2:
    ans.append(value)
  else:
    ans.appendleft(value)
print(*ans)

Submission status: Accepted

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

L = [] 
if N % 2 == 0:
    for i in range(1,N//2+1):
        L.append(2 * i)
    L = sorted(L, reverse=True)
    for i in range(1,N//2+1):
        L.append(2 * i - 1)
else:
    for i in range(1,(N + 1)// 2 + 1):
        L.append(2 * i - 1)
    L = sorted(L, reverse=True)
    for i in range(1,(N + 1)// 2):
        L.append(2 * i)
        
ans = ''
for i,j in enumerate(L):
    ans  += str(A[j-1]) + ' '
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 == 1:
    q.reverse()

for i in range(n):
    if i != n - 1:
        print("{} ".format(q[i]), end= "")
    else:
        print("{}".format(q[i]))

Submission status: Accepted

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

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])
    elif i%2==1:
        b.append(A[i])
ans=''
if n%2==0:
    for i in range(n):
        ans+=str(b[n-i-1])+' '
else:
    for i in range(n):
        ans+=str(b[i])+' '
print(ans[:-1])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

x = a[::2]
y = a[1::2]

if n%2==0:
    res = y[::-1] + x
else:
    res = x[::-1] + y

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque


def main():
    N = int(input())
    A = list(map(int, input().split()))
    q = deque()
    for i in range(N):
        if (N-i) % 2 == 1:
            q.appendleft(A[i])
        else:
            q.append(A[i])
    print(" ".join(map(str, q)))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int,input().split()))
A2 = [A[i] for i in range(1,n,2)]
A0 = [A[i] for i in range(0,n,2)]
if len(A) == 1:
    ans = A
else:
    ans = A0[::-1]
    ans += A2
if n % 2 == 0:
    ans = ans[::-1]
print(*ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
n = I()
a = LI()
b = [None for i in range(n)]
k = n//2
if n%2:
    for i in range(n):
        if i%2:
            b[k+(i+1)//2] = a[i]
        else:
            b[k-i//2] = a[i]
else:
    for i in range(n):
        if i%2:
            b[k-(i+1)//2] = a[i]
        else:
            b[k+i//2] = a[i]
print(*b)
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Accepted

Solution code:
#ABC066C
N=int(input())
A=list(map(int,input().split()))
B=[0 for n in range(N)]
for n in range(N):
	B[(-1)**(n%2)*n//2]=A[-n-1]
print(' '.join(map(str,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(" ".join(b))

Submission status: Accepted

Solution code:
def main():
    _ = int(input())
    a = [int(s) for s in input().split()]
    print(*solve(a))

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

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = ''
X = list(map(int, input().split()))
if(len(X) % 2 == 0):
    for i in range(0, n, 2):
        s += str(X[n - 1 - i])
        s += ' '
    for i in range(0, n, 2):
        s += str(X[i])
        s += ' '
else:
    for i in range(0, n, 2):
        s += str(X[n - i - 1])
        s += ' '
    for i in range(1, n, 2):
        s += str(X[i])
        s += ' '
print(s[:-1])

Submission status: Accepted

Solution code:
int_n = int(input())
ar_int_a = list(map(int, input().split()))
ar_int_b = [-1] * int_n


idx = (int_n // 2)
ar_int_b[idx] = ar_int_a[0]

if int_n % 2 == 0:
    # 偶数
    for i in range(1, int_n):
        if i % 2 == 0:
            idx = idx + i
        else:
            idx = idx + (-1 * i)
        ar_int_b[idx] = ar_int_a[i]
else:
    # 奇数
    for i in range(1, int_n):
        if i % 2 == 0:
            idx = idx + (-1 * i)
        else:
            idx = idx + i
        ar_int_b[idx] = ar_int_a[i]


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

Submission status: Accepted

Solution code:
from collections import deque
N = int(input())
A = [int(i) for i in input().split()]
lenA = len(A)

B = deque()
for i in range(N):
    if lenA % 2 == 0:
        if i % 2 == 0:
            B.append(A[i])
        else:
            B.appendleft(A[i])
    else:
        if i % 2 == 0:
            B.appendleft(A[i])
        else:
            B.append(A[i])
            
print(' '.join(map(str, B)))

Submission status: Accepted

Solution code:
n = int(input())
L = [None]+list(input().split())
even = []
odd = []
if n % 2 == 0:
    for i in range(1,1+n):
        if i % 2 == 0:
            even.append(L[i])
        else:
            odd.append(L[i])
    ans = even[::-1] + odd
else:
    for i in range(1,1+n):
        if i % 2 == 0:
            even.append(L[i])
        else:
            odd.append(L[i])
    ans = odd[::-1] + even
for i in range(n-1):
    print(ans[i],end=' ')
print(ans[n-1])

Submission status: Accepted

Solution code:
n = int(input())
L = [None]+list(input().split())
even = []
odd = []
if n % 2 == 0:
    for i in range(1,1+n):
        if i % 2 == 0:
            even.append(L[i])
        else:
            odd.append(L[i])
    ans = even[::-1] + odd
else:
    for i in range(1,1+n):
        if i % 2 == 0:
            even.append(L[i])
        else:
            odd.append(L[i])
    ans = odd[::-1] + even
for i in range(n-1):
    print(ans[i],end=' ')
print(ans[n-1])

Submission status: Accepted

Solution code:
n = int(input())
L = [None]+list(input().split())
even = []
odd = []
if n % 2 == 0:
    for i in range(1,1+n):
        if i % 2 == 0:
            even.append(L[i])
        else:
            odd.append(L[i])
    ans = even[::-1] + odd
else:
    for i in range(1,1+n):
        if i % 2 == 0:
            even.append(L[i])
        else:
            odd.append(L[i])
    ans = odd[::-1] + even
for i in range(n):
    if i == n - 1:
        print(ans[i])
    else:
        print(ans[i],end=' ')

Submission status: Accepted

Solution code:
n = int(input())
L = [None]+list(input().split())
even = []
odd = []
if n % 2 == 0:
    for i in range(1,1+n):
        if i % 2 == 0:
            even.append(L[i])
        else:
            odd.append(L[i])
    for x in even[::-1]:
        print(x,end=' ')
    for y in odd:
        print(y,end=' ')
    print()
else:
    for i in range(1,1+n):
        if i % 2 == 0:
            even.append(L[i])
        else:
            odd.append(L[i])
    for y in odd[::-1]:
        print(y,end=' ')
    for x in even:
        print(x,end=' ')
    print()

Submission status: Accepted

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

Submission status: Accepted

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

b = ['' for _ in range(n)]
m = n // 2

b[m] = a[0]

p = 1

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

if n % 2 == 1:
    b = list(reversed(b))

print(' '.join(b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
la = len(a)
res = [0] * la
s = 0
l = la - 1
if la % 2 == 0:
    for i in range(la)[::-1]:
        if i % 2 != 0:
            res[s] = a[i]
            s += 1
        else:
            res[l] = a[i]
            l -= 1
else:
    for i in range(1, la)[::-1]:
        if i % 2 == 0:
            res[s] = a[i]
            s += 1
        else:
            res[l] = a[i]
            l -= 1
    res[s] = a[0]
print(" ".join([str(i) for i in res]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = input().split()
e = []
o = []
for i in range(n//2):
    o.append(a[i*2])
    e.append(a[i*2+1])
if n % 2 == 1:
    o.append(a[-1])
    o = o[::-1]
    print(" ".join(o+e))
else:
    e = e[::-1]
    print(" ".join(e+o))

Submission status: Accepted

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

left = True
ans = deque()
while A:
    if left: ans.appendleft(A.pop())
    else: ans.append(A.pop())
    left = not left
if n % 2 == 0: ans.reverse()
print(' '.join(str(a) for a in ans))

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
  b=[str(v) for k,v in enumerate(a) if k%2==0]
  c=[str(v) for k,v in enumerate(a) if k%2==1][::-1]
  print(" ".join(c+b))
else:
  b=[str(v) for k,v in enumerate(a) if k%2==0][::-1]
  c=[str(v) for k,v in enumerate(a) if k%2==1]
  print(" ".join(b+c))

Submission status: Accepted

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

Submission status: Accepted

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

if N%2==0:
    ans1 = A[1::2][::-1]
    ans2 = A[0::2]
else:
    ans1 = A[0::2][::-1]
    ans2 = A[1::2]

print(" ".join(map(str,ans1))," ".join(map(str,ans2)))