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())
import queue
dq = queue.deque()
a_list = list(map(int,input().split()))

for i in range(n):
    if i%2 == 0:
        dq.append(a_list[i])
    else:
        dq.appendleft(a_list[i])
        
if n %2 == 0:
    print(*dq)
    
else:
    dq.reverse()
    print(*dq)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    A = input().split()
    import collections
    deq = collections.deque()
    addleft = True if N%2==1 else False
    for a in A:
        if addleft:
            deq.appendleft(a)
        else:
            deq.append(a)
        addleft = (not addleft)
    print(" ".join(deq))

if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

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

Submission status: Accepted

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

from collections import deque    
q = deque([])

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

Submission status: Accepted

Solution code:
from collections import deque
def main():
    n, a, b = int(input()), list(map(int, input().split())), deque()
    append, appendleft = b.append, b.appendleft
    flag = True
    for el in a:
        if flag: append(el)
        else: appendleft(el)
        flag = not flag
    if not flag: b.reverse()
    print(" ".join(list(map(str, b))))
main()

Submission status: Accepted

Solution code:
from collections import deque
n, a, b = int(input()), list(map(int, input().split())), deque()
append, appendleft = b.append, b.appendleft
flag = True
for i in range(n):
    if flag: append(a[i])
    else: appendleft(a[i])
    flag = not flag
if not flag: b.reverse()
print(" ".join(list(map(str, b))))

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    N = int(readline())
    A = list(map(int, readline().rstrip().split()))
    que = deque([])
    for i, a in enumerate(A):
        if i % 2 == 0:
            que.append(a)
        else:
            que.appendleft(a)
    
    if N % 2 == 1:
        que = list(que)[::-1]
    print(*que)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

gu_li = []
ki_li = []
for i in range(0,n):
    if i%2 == 1:
        gu_li.append(li[i])
    else:
        ki_li.append(li[i])

ans = []
if n % 2 == 0:
    ans += list(reversed(gu_li)) + ki_li
else:
    ans += list(reversed(ki_li)) + gu_li
#print(ans)
print(*ans)

Submission status: Accepted

Solution code:
from collections import deque

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

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

Submission status: Accepted

Solution code:
from collections import deque

n, *a = map(int, open(0).read().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:
    for i in range(n):
        print(b[i], end=' ')
else:
    for i in reversed(range(n)):
        print(b[i], end=' ')

Submission status: Accepted

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

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

print(*ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def print_data(a, flag):
    for i in range(n - 1, -1, -2):
        print(a[i], end = " ")
    
    for i in range(0 + flag, n, 2):
        print(a[i], end = " ")
    
    print()


if n % 2 == 0:
    print_data(a, 0)
else:
    print_data(a, 1)

Submission status: Accepted

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

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

if r:
    b = reversed(b)
ans = ' '.join(b)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
print(*a[::-2] + a[int(n)%2::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])
d = list(d)
if n % 2 == 1:
    d.reverse()
print(*d)

Submission status: Accepted

Solution code:
n, a = open(0)
a = a.split()
print(*a[::-2] + a[int(n)%2::2])

Submission status: Accepted

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

Submission status: Accepted

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

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-i*2])
  for i in range(n//2):
    ans.append(a[i*2])
else:
  for i in range(n//2+1):
    ans.append(a[n-1-i*2])
  for i in range(n//2):
    ans.append(a[i*2+1])
print(*ans)

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.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()))
ushiro=[a[i] for i in range(n) if i%2==0]#if_n%2==0_it_will_be_behind
mae=[a[i] for i in range(n) if i%2==1]
p=mae[::-1]+ushiro
if n%2==0:
    print(*p)
else:
    print(*p[::-1])

Submission status: Accepted

Solution code:
import collections
def slove(n, a):
    b = collections.deque()

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

if __name__ == "__main__":
    n = int(input())
    a_list = [i for i in input().split()]
    print(slove(n, a_list))

Submission status: Accepted

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

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

Submission status: Accepted

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

b1 = []
b2 = []

for i in range(n):
    if flag:
        b1.append(a[i])
    else:
        b2.append(a[i])
    flag ^= 1
b2.reverse()
ans = b2+b1
if not flag:
    ans.reverse()
print(*ans)

Submission status: Accepted

Solution code:
from collections import deque

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

b = deque()

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b1 = []
b2 = []
for i in range(n):
    if i % 2 == 0:
        b1.append(a[i])
    else:
        b2.append(a[i])
if n % 2 == 0:
    b2.reverse()
    b = b2 + b1
else:
    b1.reverse()
    b = b1 + b2
    
print(' '.join(map(str, 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(a[i])
    if i % 2 == 1:
        c.append(a[i])
c.reverse()
c += b
if n % 2 == 1:
    c.reverse()
print(*c)

Submission status: Accepted

Solution code:
from collections import deque
n, *A = map(int, open(0).read().split())
B = deque()

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

Submission status: Accepted

Solution code:

from collections import  deque
n = int(input())
lst = list(input().split())
reverse = False
b = deque()
for a in lst:
	if reverse:
		b.appendleft(a)
	else:
		b.append(a)
	reverse = not reverse

answer =[]
if reverse:
	while b:
		answer.append(b.pop())
else:
	while b:
		answer.append(b.popleft())

print(" ".join(answer))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

n = int(input())
a = list(map(int, input().split()))
s = deque([])

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

B_left = []
B_right = []
for i, a in enumerate(A):
    if i % 2 == 0:
        B_right.append(a)
    else:
        B_left.append(a)

if len(A) % 2 == 0:
    B = B_left[::-1] + B_right
else:
    B = B_right[::-1] + B_left
print(*B)

Submission status: Accepted

Solution code:

url = "https://atcoder.jp//contests/abc066/tasks/arc077_a"

def main():
    input()
    t = list(map(int, input().split()))
    left = []
    right = []
    ans = [0] * len(t)
    for i in range(len(t)):
        if (len(t) - (i + 1) ) % 2 == 0:
            left.append(t[i])
        else:
            right.append(t[i])
    print(' '.join([str(v) for v in left[::-1]]), ' '.join([str(v) for v in right]))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
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(*(list(reversed(l))+r))
else:
  print(*(list(reversed(r))+l))

Submission status: Accepted

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

for i in range(n):
    if (i+1)%2==0:
        R.append(a[i])
    else:
        L.append(a[i])

#print(R,L)

if n%2==0:
    R.reverse()
    print(*R+L)
else:
    L.reverse()
    print(*L+R)

Submission status: Accepted

Solution code:
import sys
from collections import deque

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

def main():
    b = deque()
    for i in range(n):
        if (i & 1): b.appendleft(a[i])
        else: b.append(a[i])
    if (n & 1): b.reverse()
    print(*b, sep=' ')

if __name__ ==  '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int, input().split()))
a_gu=a[0::2]
a_ki=a[1::2]
if len(a)%2==0:
    a_ki.reverse()
    a_ki.extend(a_gu)
    print(' '.join(map(str,a_ki)))
else:
    a_gu.reverse()
    a_gu.extend(a_ki)
    print(' '.join(map(str,a_gu)))

Submission status: Accepted

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

Submission status: Accepted

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

for i,x in enumerate(a):
    if i%2==1:
        b.appendleft(x)
    else:
        b.append(x)
if n%2==1:
    for i in list(b)[::-1]:
        print(i)
else:
    for i in b:
        print(i)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

if n >= 2:
  print(' '.join(d))
else:
  print(a[0])

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
fw = [a for i,a in enumerate(A) if i%2 == 0]
bw = [a for i,a in enumerate(A) if i%2 == 1]
if len(A) % 2 == 0:
  ans = list(reversed(bw)) + fw
else:
  ans = list(reversed(fw)) + bw
print(' '.join([str(a) for a in ans]))

Submission status: Accepted

Solution code:
n,*a=map(int,open(0).read().split())
if len(a)%2:
  print(' '.join(map(str,a[::-2]+a[1::2])))
else:
  print(' '.join(map(str,a[::-2]+a[::2])))

Submission status: Accepted

Solution code:
from collections import deque
b = deque()
n = int(input())
ns = map(int, input().split())
for i, j in enumerate(ns):
    if i%2 == 0:
        b.append(j)
    else:
        b.appendleft(j)
b = list(map(str, b))
if i%2 == 0:
    b = b[::-1]
    print(' '.join(b))
else:
    print(' '.join(b))

Submission status: Accepted

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def main():
  n = int(input())
  *A, = map(int,input().split()) # こうすることで、当データとidxが取得できる！！！つよ！！
  from collections import deque
  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)
if __name__ == '__main__':
  main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
A = input().split()
ans = deque()
cnt = 1
for a in A:
    if cnt%2==n%2: ans.appendleft(a)
    else: ans.append(a)
    cnt+=1
print(' '.join(ans))

Submission status: Accepted

Solution code:
N = int(input())
ARR = [int(s) for s in input().split(" ")]
def calculate(n,arr):

    left = list([])
    right = list([])
    if n % 2 == 0:
        for index,ar in enumerate(arr):
            if index % 2 == 0:
                right.append(str(ar))
            else:
                left.append(str(ar))
    else:
        for index,ar in enumerate(arr):
            if index % 2 == 0:
                left.append(str(ar))
            else:
                right.append(str(ar))

    left.reverse()
    left.extend(right)

    return left

result = calculate(N,ARR)
print(" ".join(result))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, *a_l = map(int, open(0).read().split())
b = []

for a in a_l[::-2]:
        b.append(a)
for a in a_l[n%2::2]:
        b.append(a)

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

Submission status: Accepted

Solution code:
from collections import deque
n=int(input())
a=list(map(int,input().split()))
if n==1:
    print(a[0])
else:
    ans=deque()
    ans.append(a[0])
    if (n-1)%2==0:
        s=0 #うしろ
    else:
        s=1
    for i in range(1,n):
        if s==0:
            ans.append(a[i])
        else:
            ans.appendleft(a[i])
        s=(s+1)%2
    for i in range(n):
        print(ans[i],end=" ")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
queue=deque()

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

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

answer = []
if n % 2 == 1:
  for i in range(n):
    answer.append(queue.pop())
else:
  for i in range(n):
    answer.append(queue.popleft())
    
print(*answer)

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
a = [int(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])

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

b = list(b)

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

Submission status: Accepted

Solution code:
from collections import deque


N = int(input())
A = list(map(int, input().split()))
q = deque()
for i, a in enumerate(A):
    if i % 2 == 0:
        q.append(a)
    else:
        q.appendleft(a)

ans = []
if len(A) % 2 == 1:
    while q:
        ans.append(q.pop())
else:
    while q:
        ans.append(q.popleft())

print(*ans)

Submission status: Accepted

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

b = collections.deque()

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
from collections import deque

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

n = i_i()
a = i_l()

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:
def main():
    n = int(input())
    data = list(map(int, input().split()))

    if n == 1:
        print(data[0])
    else:
        result = [None] * n

        if n % 2 == 0:
            center = int(n / 2)
            for index, value in enumerate(data):
                if index % 2 == 0:
                    result[center + int(index / 2)] = value
                else:
                    result[center - int((index + 1) / 2)] = value
            print(" ".join(str(n) for n in result))
        else:
            center = int(n / 2)
            for index, value in enumerate(data):
                if index % 2 == 0:
                    result[center - int(index / 2)] = value
                else:
                    result[center + int((index + 1) / 2)] = value
            print(" ".join(str(n) for n in result))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np
from collections import deque
n = int(input())
a_ls = list(map(int, input().split()))
q = deque(a_ls)

if n != 1:
    l_ls = [0] * int(np.floor(0.5*n))
    r_ls = [0] * max(0,(n-1)//2)
    first = q.popleft()
    count = 2
    while True:
        a = q.popleft()
        if count % 2 == 0:
            l_ls[count//2-1] = a
        else:
            r_ls[count//2-1] = a
        count += 1
        if count > n:
            break
    ans = []
    if n % 2 ==0:
        for i in range(len(l_ls)):
            l = l_ls.pop()
            ans.append(l)
        ans.append(first)
        for i in range(len(r_ls)):
            ans.append(r_ls[i])
    else:
        for i in range(len(r_ls)):
            l = r_ls.pop()
            ans.append(l)
        ans.append(first)
        for i in range(len(l_ls)):
            ans.append(l_ls[i])

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

else:
    print(a_ls[0])

Submission status: Accepted

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

bl=[]
br=[]
if n%2==0:
    for i in range(0,n-1,2):
        bl.append(a[i]) 
        br.append(a[i+1]) 
    br.reverse()
    br=br+bl
else:
    for i in range(0,n-2,2):
        bl.append(a[i]) 
        br.append(a[i+1]) 
    bl.append(a[n-1]) 
    bl.reverse()
    br=bl+br
    
for i in range(len(br)):
    print(br[i],end=" ")
print()

Submission status: Accepted

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

if n%2 == 0:
    inds = list(range(n-1,0,-2)) + list(range(0,n,2))
else:
    inds = list(range(n-1,-1,-2)) + list(range(1,n,2)) 

Bs = [As[i] for i in inds]
print(*Bs)

Submission status: Accepted

Solution code:
from collections import deque

def main():
    n = int(input())
    a = list(map(int, input().split()))
    r = deque()
    for ia in range(n):
        if ia % 2 == 1:
            r.appendleft(a[ia])
        else:
            r.append(a[ia])

    if n % 2 == 1:
        r.reverse()
    for i in range(n):
        print(r[i], end = ' ')



if __name__ == '__main__':
    main()

Submission status: Accepted

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

from collections import deque
b = deque([])
if len(a) % 2 == 0:
    for i in range(1, N + 1):
        #print(b)
        if i % 2 == 0:
            b.appendleft(a[i - 1])
        else:
            b.append(a[i - 1])
else:
    for i in range(1, N + 1):
        #print(b)
        if i % 2 == 0:
            b.append(a[i - 1])
        else:
            b.appendleft(a[i - 1])

print(' '.join([str(i) for i in b]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import collections


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

    result = collections.deque()

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())
l = input().split()
d = deque()
for idx, i in enumerate(l):
    if (idx +1) % 2 == 1:
        d.appendleft(i)
    else:
        d.append(i)
if n % 2 == 0:
    d.reverse()
print(' '.join(d))

Submission status: Accepted

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

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

for i in range(n):
    print(d.popleft(),end=' ')

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import deque

n = ni()
a = na()

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

if n % 2 == 0:
    for i in range(n):
        if i:
            print(" ", end="")
        print(q.popleft(), end="")
    print()
else:
    for i in range(n):
        if i:
            print(" ", end="")
        print(q.pop(), end="")
    print()

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

o = b.pop if n%2 else b.popleft

for i in range(n):
    print(o(), end=' ')

Submission status: Accepted

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

d = deque()
e=[]
for i in range (x):
	if i%2==0:
		d.append(y[i])
	else:
		d.appendleft(y[i])
if i%2==0:
	for i in range(x):
		e.append(d[((-i)-1)])
	print(*(list(e)))
else:
	print(*(list(d)))

Submission status: Accepted

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

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:
    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(map(int,input().split()))
b1 = []
b2 = []
for i in range(n):
    if i%2==0:b1.append(a[i])
    else:b2.append(a[i])

if n%2==0:
    b2.reverse()
    print(*b2+b1)
else:
    b1.reverse()
    print(*b1+b2)