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 math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

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

def main():
  n=I()
  l=LS()

  l1=[]
  l2=[]

  for i in range(len(l)):
    if i%2==0:
      l1.append(l[i])
    else:
      l2.append(l[i])

  if n%2==0:
    l2.reverse()
    l2+=l1
    return ' '.join(str(x) for x in l2)
  else:
    l1.reverse()
    l1+=l2
    return ' '.join(str(x) for x in l1)

print(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 = ' ')
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:
n=int(input())
l=list(map(int,input().split()))
if n%2==1:
  l=l[n-1::-2]+l[1::2]
  for i in range(n):
    print(l[i],end=" ")
else:
  l=l[n-1::-2]+l[::2]
  for i in range(n):
    print(l[i],end=" ")

Submission status: Accepted

Solution code:
n = int(input())

b = ["#"] * n

li = list(input().split())

if n % 2 == 0:
    for i in range(n):
        if i == 0:
            s = (n//2)
        b[s] = li[i]

        if i != n-1:
            if i % 2 == 0:
                s = s-i-1
            else:
                s = s+i+1
else:
    for i in range(n):
        if i == 0:
            s = n//2
        b[s] = li[i]
        
        if i != n-1:
            if i % 2 == 0:
                s = s+i+1
            else:
                s = s-i-1

        
print(*b)

Submission status: Accepted

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

n = int(input())
a = list(map(int, input().split()))
be = []
af = []
for i in range(math.floor(n/2)):
    be.append(a[n-(2*i)-1])
    af.append(a[n-(2*i)-2])
af.reverse()
if n%2 == 1:
    ans = be + [a[0]] + af
else:
    ans = be + af
for i in range(n):
    print(ans[i], end=' ')
print('\n')

Submission status: Accepted

Solution code:
n = int(input())

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

ans = a[::-2] + a[len(a)%2::2]

print(*ans)

Submission status: Accepted

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

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

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

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

for i in b:
    print('{} '.format(i), end='')
print()

Submission status: Accepted

Solution code:
# 適当に1~6くらいまでの数列でやると法則がみえてくるのでそうする
# nが偶数 -> 後ろから偶数番目を降順で、のちに頭から奇数を昇順で
# nが奇数 -> 後ろから奇数番目を降順で、のちに頭から偶数を昇順で

n = int(input())
arr = input().split()
pre, epi = [], []
if n % 2 == 0:
    pre = arr[::-2]
    epi = arr[::2]
else:
    pre = arr[-1::-2]
    epi = arr[1::2]
print(" ".join(pre), end=" ")
print(" ".join(epi))

Submission status: Accepted

Solution code:
n = int(input())
l,r = [],[]
for i,a in enumerate([int(i) for i in input().split()]):
    if (n%2 == 0 and (i+1)%2 == 0) or (n%2 == 1 and (i+1)%2 == 1):
        l.append(str(a))
    else:
        r.append(str(a))
for a in l[::-1]:
    print(a,end=' ')
for b in r:
    print(b,end=' ')
print()

Submission status: Accepted

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

i = n-1
while i >= 0:
    print a[i],
    i -= 2

i = n % 2
while i < n:
    print a[i],
    i +=2

Submission status: Accepted

Solution code:
import collections


def main():
    n = int(input())
    a = [int(ele) for ele in input().split()]
    b = collections.deque()

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

    if ct % 2 == 0:
        print(" ".join(list(b)[::-1]))
    else:
        print(" ".join(list(b)))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

B_right = A[0::2]
B_left = list(reversed(A[1::2]))

B_left.extend(B_right)
ans = B_left

if len(A)%2 == 1:
  ans = list(reversed(ans))

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

Submission status: Accepted

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

import collections
q = collections.deque([])
c = 1
q.append((dat_a[0]))
while True:
    if c == len(dat_a):
        break
    q.appendleft(dat_a[c])
    c += 1

    if c == len(dat_a):
        break
    q.append(dat_a[c])
    c += 1

res = list(q)

if n %2  == 1:
    res.reverse()
res = map(str, res)
print(" ".join(res))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
ev = a[1::2]
od = a[::2]
if n % 2 == 0:
    ev = ev[::-1]
    ans = ev + od
else:
    od = od[::-1]
    ans = od + ev
print(" ".join(map(str, ans)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC066C - pushpush (ARC077)
from collections import deque

n = int(input())
lst = list(map(int, input().rstrip().split()))
b = deque()
parity = n % 2
for i, j in enumerate(lst, start=1):
    if i % 2 == parity:
        b.appendleft(j)
    else:
        b.append(j)
print(*b)

Submission status: Accepted

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


answer = arr[::2][::-1] + arr[1::2]
if not N&1:
  answer = answer[::-1]
  
print(*answer,sep=' ')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

l.reverse()

ans = [0]*n
head = 0
tail = n-1
    
for i in range(n):
    if i % 2 == 0:
        ans[head] = l[i]
        head += 1
        
    else:
        ans[tail] = l[i]
        tail -= 1


for i in range(n):
    ans[i] = str(ans[i])

print(' '.join(ans))

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

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

def main():
  n=I()
  l=LI()

  if n==1:
    return l[0]

  cen=l[0]
  l.remove(cen)

  la=[]
  lb=[]
  for i in range(len(l)):
    if i%2==0:
      la.append(l[i])
    else:
      lb.append(l[i])

  if n%2==0:
    la.reverse()
    return ' '.join(str(x) for x in la)+' '+str(cen)+' '+' '.join(str(x) for x in lb)
  else:
    lb.reverse()
    return ' '.join(str(x) for x in lb)+' '+str(cen)+' '+' '.join(str(x) for x in la)

print(main())

Submission status: Accepted

Solution code:
import itertools
import math
N = int(input())
As = list(map(int,input().split(" ")))
ans = []
off = 0
if N%2 == 1:
    off = 1

for i in range(N-1,-1,-2):
    ans.append(As[i])
for i in range(off,N,2):
    ans.append(As[i])
ans = list(map(str,ans))
print(" ".join(ans))

Submission status: Accepted

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

even_lst = [A[i] for i in range(N) if i % 2 == 1]
odd_lst = [A[i] for i in range(N) if i % 2 == 0]

if N % 2 == 0:
  progression = even_lst[::-1] + odd_lst
else:
  progression = odd_lst[::-1] + even_lst

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))[::-1]

L = A[::2]
R = A[1::2]

print(*(L+R[::-1]))

Submission status: Accepted

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

odd = A[0::2]
even = A[1::2]

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

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

Submission status: Accepted

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

if(N==1):
    print(a[0])
elif(N%2==0):
    for i in range(N-1,-1,-2):
        print(a[i],end=' ')
    for i in range(0,N-2,+2):
        print(a[i],end=' ')
    print(a[N-2])
else:
    for i in range(N-1,-1,-2):
        print(a[i],end=' ')
    for i in range(1,N-2,+2):
        print(a[i],end=' ')
    print(a[N-2])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
num_list = [ v for v in input().split() ]

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
cnt=n-1
i=n
arg=[0]*n
while(cnt>=0):
     arg[n-i]=cnt
     cnt-=1
     if cnt<0:
          break
     arg[i-1]=cnt
     cnt-=1
     i-=1
b=[]
for idx in arg:
     b.append(str(a[idx]))
print(' '.join(b))

Submission status: Accepted

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

Submission status: Accepted

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

l = len(A)
b = [0]*N
for i, a in enumerate(A):
    if i % 2 == 0:
        b[(l//2) + (i//2)] = a
    else:
        b[(l//2) - (i//2) - 1] = a

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

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,*a=map(int,open(0).read().split())
b=a[1::2][::-1]+a[::2]
print(*b[::n%2<1or-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
A = [(i if i % 2 == 0 else -i, x) for i, x in enumerate(input().split())]
print(" ".join(map(lambda x: x[1], sorted(A, reverse=len(A)%2 ==1))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc066/tasks/arc077_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

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

    i = len(a) - 1
    while i >= 0:
        print(a[i], end=" ")
        i -= 2

    i = 1 if i == -2 else 0
    while i < len(a):
        print(a[i], end=" ")
        i += 2


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if n%2 == 0:
    left = list(reversed(a[1::2]))
    right = a[::2]
    ans = left + right
else:    
    left = list(reversed(a[2::2]))
    right = a[1::2]
    ans = left +[a[0]]+ right
    
print(' '.join(map(str,ans)))

Submission status: Accepted

Solution code:
# 2019/05/24
# AtCoder Beginner Contest 066 - C

# For the answer:
# Odd:(n==9)
# 753102468
# Even:(n==8)
# 75310246

# Input
n = int(input())
a = list(input().split())
ansl = list()

# Calc Start Index
if n % 2 == 1:
    sidx = n - 2
else:
    sidx = n - 1

# Append Left
for i in range(sidx, -1, -2):
    ansl.append(a[i])

# Append Right
for i in range(0, n, 2):
    ansl.append(a[i])

# Case odd: Reverse list
if n % 2 == 1:
    ansl.reverse()

# Make Output String
ans = ""
for i in range(n):
    ans += ansl[i] + " "

# Output
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
s=input().split(" ")
s1=[]
s2=[]
even=True
for z in s:
  if even:
    s1.append(z)
    even=False
  else:
    s2.append(z)
    even=True

if even:
  print(" ".join(s2[::-1]+s1))
else:
  print(" ".join(s1[::-1]+s2))

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-1,2):
        ans.append(a[i])
else:
    for i in range(n-1,-1,-2):
        ans.append(a[i])
    for i in range(1,n-1,2):
        ans.append(a[i])
print(' '.join(map(str,ans)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

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

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

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

Submission status: Accepted

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

def solve():
    n = int(input())
    A = input().split()

    """方針
    A = 0 6 7 6 7 0
    i | b
    ---------------
    1 | 0
    2 | 0 6 (本当は逆で6 0)
    3 | 7 0 6
    4 | 7 0 6 6 (本当は逆で 6 6 0 7)
    5 | 7 7 0 6 6
    6 | 7 7 0 6 6 0 (本当は逆で0 6 6 0 7 7) 

    ・iが偶数のとき、bの後ろにA[i]を追加する
    ・iが奇数のとき、bの前にA[i]を追加する

    上の操作をn回すべてしたあとに、

    ・nが偶数なら答えを反転する
    ・nが奇数なら答えはそのまま

    ただし、A[i]は2桁以上の数字の可能性も考慮すること

    あとPythonは、list.insert()はとても遅いので（TLEしたので）、代わりにcollections.dequeを使用する

    ・collections.deque
    https://docs.python.org/ja/3/library/collections.html#collections.deque

    dequeとは、「両端における append や pop を高速に行えるリスト風のコンテナ」
    """

    # 1 2 3 -> 3 1 2
    b = deque()
    for i in range(1, n+1):
        if i%2 == 0:
            b.append(A[i-1])
        else:
            b.appendleft(A[i-1])

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


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

n = int(input())
s = input().split()
q = deque()

for i in range(n):
  if i%2 == 0:
    q.appendleft(s[i])
  else:
    q.append(s[i])
if n%2 == 0:
  q.reverse()
print(" ".join(q))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
A = input().split()
even = []
odd = []
for i in range(len(A)):
  if i % 2 == 0:
    even.append(A[i])
  else:
    odd.append(A[i])
if N % 2 == 0:
    even, odd = odd, even
print(*(even[::-1]+odd))
# print(even, odd)

Submission status: Accepted

Solution code:
n=int(input())
a_list=[int(i) for i in input().split()]
odd=[a_list[i] for i in range(n) if i%2==1]
even=[a_list[i] for i in range(n) if i%2==0]

ans=[]
if n%2==1:
    even.reverse()
    ans=even+odd
else:
    odd.reverse()
    ans=odd+even
print(' '.join(map(str, ans)))

Submission status: Accepted

Solution code:
from collections import deque
q=deque()
r=int(input())%2
for x in map(int, input().split()):
	if r == 0:
		q.append(x)
	else:
		q.appendleft(x)
	r = 1 - r
print(" ".join(map(str, q)))

Submission status: Accepted

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
import math


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

if N%2 == 0:
  Bn = An[-1::-2] + An[0::2]
else:
  Bn = An[-1::-2] + An[1::2]

for b in Bn:
  print(b,end=" ")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque


n = int(input())
lst_a = list(map(int, input().split()))
b = deque([])


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


print(*b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque


n = int(input())
lst_a = list(map(int, input().split()))
b = deque([])


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


print(*b)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import deque

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

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

Submission status: Accepted

Solution code:
from collections import deque

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

Q = deque()

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

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

#操作回数が奇数回で逆順、偶数回で元の順
b = []
for i in range(N-1, -1, -2):
    b.append(a[i])
if N % 2:
    s = 1
else:
    s = 0
for i in range(s, N, 2):
    b.append(a[i])

print(*b)

Submission status: Accepted

Solution code:
import sys
from collections import deque
input = sys.stdin.readline
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.appendleft(A[i])
        else:
            ans.append(A[i])
else:
    for i in range(n):
        if i % 2 == 0:
            ans.append(A[i])
        else:
            ans.appendleft(A[i])

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

Submission status: Accepted

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

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

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

mapB = map(str,B)
B = ' '.join(mapB)
print(B)

Submission status: Accepted

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

N = int(input())
L = [int(v) for v in input().split()]
res = deque()

for i in range(N):
    if i % 2 == 0:
        res.append(str(L[i]))
    else:
        res.appendleft(str(L[i]))
        
if N % 2 == 0:
    print(" ".join(res))
else:
    print(" ".join(reversed(res)))

Submission status: Accepted

Solution code:
#ABC066C
import pprint
n = int(input())
ai = list(map(int, input().split()))
bi = []
ran = 0
if n%2==0:
    for i in range(n//2):
        bi.append(ai[i+i+1])
    bi.reverse()
    for i in range(n//2):
        bi.append(ai[i+i])
else:
    for i in range(n//2+1):
        bi.append(ai[i+i])
    bi.reverse()
    for i in range(n//2):
        bi.append(ai[i+i+1])
        
for b in bi:
    print(b, end=" ")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
"""
b = []
for i, a in enumerate(A):
	if not i % 2:
		b.append(a)
	else:	
		b.insert(0, a)

if not len(A) % 2:
	print(*b)
else:
	print(*b[::-1])
"""
print(*(A[::-2] + A[len(A) % 2::2]))

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

o = [0] * n
c = n//2
r = c
l = c - 1
for i in range(n):
    if i % 2:
        o[l] = a[i]
        l -= 1
    else:
        o[r] = a[i]
        r += 1

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

Submission status: Accepted

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

i = n - 1
while i >= 0:
    print(a[i], end=' ')
    i -= 2

if n % 2 == 1:
    i = 1
else:
    i = 0

while i <= n - 1:
    print(a[i], end=' ')
    i += 2

print()

Submission status: Accepted

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

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

print(" ".join(b))

Submission status: Accepted

Solution code:
from collections import Counter
from functools import reduce
# import statistics
import bisect
import copy
import fractions
import math
import pprint
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) 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 MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)


n = II()
a = LI()
length = len(a)
odd = [a[i] for i in range(length) if i % 2 == 0]
even = [a[i] for i in range(length) if i % 2 == 1]
if length % 2 == 0:
    print(' '.join(map(str, even[::-1])) + ' ' + ' '.join(map(str, odd)))
else:
    print(' '.join(map(str, odd[::-1])) + ' ' + ' '.join(map(str, even)))

Submission status: Accepted

Solution code:

from collections import deque

def read_input():
    n = int(input())
    alist = list(map(int, input().split()))

    return n, alist


def submit():
    n, alist = read_input()
    b = deque()

    if n % 2 == 0:
        side = 'right'
    else:
        side = 'left'

    for a in alist:
        if side == 'left':
            b.appendleft(a)
            side = 'right'
        else:
            b.append(a)
            side = 'left'


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


if __name__ == '__main__':
    submit()

Submission status: Accepted

Solution code:
from collections import deque
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = deque([])
flg = False
if n % 2 == 0:
    flg = True
for e in a:
    if flg:
        b.append(e)
        flg = False
    else:
        b.appendleft(e)
        flg = True
print(' '.join(map(str, b)))

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math


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

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

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

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

Submission status: Accepted

Solution code:
def c_pushpush(N, A):
    from collections import deque
    ans = deque([])  # リストの先頭への挿入はO(要素数)なので
    n_parity = N & 1
    for i, a in enumerate(A, 1):
        if n_parity == i & 1:
            ans.appendleft(a)
        else:
            ans.append(a)
    return ' '.join(map(str, ans))

N = int(input())
A = [int(i) for i in input().split()]
print(c_pushpush(N, A))

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)

n = ip()                                     #入力整数1つ
#a,b,t= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#k = ip()                      #入力セット(整数改行あり)(1/2)
#v=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
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:
N=int(input())
A=list(map(int,input().split()))
ans=[0 for i in range(N)]
c=0
d=0
for i in range(N):
        if N%2==0:
                if i%2==0:
                        ans[N//2+c]=A[i]
                        c+=1
                else:
                        ans[N//2-1-d]=A[i]
                        d+=1
        else:
                if i%2==0:
                        ans[N//2-d]=A[i]
                        d+=1
                else:
                        ans[N//2+1+c]=A[i]
                        c+=1 
print(*ans,sep=" ")

Submission status: Accepted

Solution code:
input();*A,=input().split();print(" ".join(A[::-2]+A[len(A)%2::2]))