Problem:


Insertion Sort

Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:

for i = 1 to A.length-1
    key = A[i]
    /* insert A[i] into the sorted sequence A[0,...,j-1] */
    j = i - 1
    while j >= 0 and A[j] > key
        A[j+1] = A[j]
        j--
    A[j+1] = key

Note that, indices for array elements are based on 0-origin.

To illustrate the algorithms, your program should trace intermediate result for each step.

Input

The first line of the input includes an integer N, the number of elements in the sequence.

In the second line, N elements of the sequence are given separated by a single space.

Output

The output consists of N lines. Please output the intermediate sequence in a line for each step. Elements of the sequence should be separated by single space.

Constraints

1 ≤ N ≤ 100

Sample Input 1

6
5 2 4 6 1 3

Sample Output 1

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

Sample Input 2

3
1 2 3

Sample Output 2

1 2 3
1 2 3
1 2 3

Hint

Template in C



Sample input:
6
5 2 4 6 1 3


Sample output:
5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6

Submission status: Wrong Answer

Solution code:
#16D8101014F 久留米 竜之介 Utyan0604 python3
def insertionsort(n,A):
	for i in range(n):
		t=A[i]
		j=i-1
		while j>=0 and A[j] > t:
			A[j+1]=A[j]
			j-=1
			A[j+1]=t
			for k in range(n):
				print(A[k],end=" ")
			print()


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


insertionsort(n,A)

Submission status: Wrong Answer

Solution code:
#16D8101014F 久留米 竜之介 Utyan0604 python3
def insertionsort(n,A):
	for i in range(n):
		t=A[i]
		j=i-1
		for k in range(n):
				print(A[k],end=" ")
		print()
		
		while j>=0 and A[j] > t:
			A[j+1]=A[j]
			j-=1
			A[j+1]=t
			
n=int(input())
A=list(map(int, input().split()))


insertionsort(n,A)

Submission status: Wrong Answer

Solution code:
#16D8101014F 久留米 竜之介 Utyan0604 python3
def insertionsort(n,A):
	for i in range(n):
		t=A[i]
		j=i-1
		while j>=0 and A[j] > t:
			A[j+1]=A[j]
			j-=1
			A[j+1]=t
			
			
	
	for k in range(n):
		if k<n-1:
			print(A[k],end=" ")
		else:
			print(A[k])
			
n=int(input())
A=list(map(int, input().split()))

insertionsort(n,A)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
print(" ".join(list(map(str, A))))
for i in range(1, N-1):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(" ".join(list(map(str, A))))

Submission status: Wrong Answer

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

for i in range(len(l)):
    v=l[i]
    j=i-1
    while j>=0 and l[j]>v:
        l[j+1]=l[j]
        j=j-1
    l[j+1]=v

    print(*l)

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
    for i in range(1,N):
        v=A[i]
        j=i-1
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j-=1
            A[j+1]=v
        print(A)
    return A

N=int(input())
A=input().split()
insertionSort(A,N)

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
    for i in range(1,N):
        v=A[i]
        j=i-1
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j-=1
            A[j+1]=v
        for i in range(N):
            if i!=N-1:
                print(A[i],end=" ")
            else:
                print(A[i])
    return A

N=int(input())
A=input().split()
insertionSort(A,N)

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
    for i in range(1,N):
        v=A[i]
        j=i-1
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j-=1
            A[j+1]=v
        for i in range(N):
            if i!=N-1:
                print(A[i],end=" ")
            else:
                print(A[i])
    return A

N=int(input())
A=[0]*N
A=input().split()
insertionSort(A,N)

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
    for i in range(1,N):
        v=A[i]
        j=i-1
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j-=1
            A[j+1]=v
        for i in range(N):
            if i!=N-1:
                print(A[i],end=" ")
            elif i==N-1:
                print(A[i])
    return A

N=int(input())
A=[0]*N
A=input().split()
insertionSort(A,N)

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
    for i in range(1,N):
        v=A[i]
        j=i-1
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j-=1
            A[j+1]=v
        for i in range(N):
            if i!=N-1:
                print(A[i],end=" ")
            if i==N-1:
                print(A[i])
    return A

N=int(input())
A=[0]*N
A=input().split()
insertionSort(A,N)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0]*N
A=input().split()
for i in range(1,N):
    v=A[i]
    j=i-1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j-=1
        A[j+1]=v
    for i in range(N):
        if i!=N-1:
            print(A[i],end=" ")
        if i==N-1:
            print(A[i])

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0 for i in range(N)]
A=input().split()
for i in range(1,N):
    v=A[i]
    j=i-1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j-=1
        A[j+1]=v
    for i in range(N):
        if i!=N-1:
            print(A[i],end=" ")
        if i==N-1:
            print(A[i])

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0 for i in range(N)]
A=input().split()
for i in range(N):
    v=A[i]
    j=i-1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j-=1
        A[j+1]=v
    for i in range(N):
        if i!=N-1:
            print(A[i],end=" ")
        if i==N-1:
            print(A[i])

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0 for i in range(N)]
A=input().split()
for i in range(N):
    v=A[i]
    j=i-1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j=j-1
        A[j+1]=v
    for i in range(N):
        if i!=N-1:
            print(A[i],end=" ")
        if i==N-1:
            print(A[i])

Submission status: Wrong Answer

Solution code:
# リストの宣言
A = []

# 入力の最初の行に、数列の長さを表す整数 N が与えられます。
# 2 行目に、N 個の整数が空白区切りで与えられます。
NUM =int(input())
A = input().split()

NUMLIST = range (1, NUM)

# for i = 1 to A.length-1
for i in NUMLIST:
#    key = A[i]
  key = A[i]
  j = i - 1
  while j >= 0 and int(A[j]) > int(key):
    A[j+1] = A[j]
    j-=1
  A[j+1] = key

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input().split()
b=[int(i) for i in a]
print(b)
i=0
for i in range(1,n):
  v=b[i]
  j=i-1
  while j>=0 and b[j]>v:
    b[j+1]=b[j]
    j-=1
  b[j+1]=v
  print(b)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input().split()
b=[int(i) for i in a]
i=0
for i in range(1,n):
  v=b[i]
  j=i-1
  while j>=0 and b[j]>v:
    b[j+1]=b[j]
    j-=1
  b[j+1]=v
  print(b)

Submission status: Wrong Answer

Solution code:
def Isort(a,n):
    for i in range(1,n):
        v = a[i]
        j = i-1
        while(j>=0 and a[j]>v):
            a[j+1] = a[j]
            j-=1
        a[j+1] = v
        print(*a)
    
n = int(input("n:"))
a = input().split()
Isort(a,n)

Submission status: Wrong Answer

Solution code:
def Isort(a,n):
    for i in range(1,n):
        v = a[i]
        j = i-1
        while(j>=0 and a[j]>v):
            a[j+1] = a[j]
            j-=1
        a[j+1] = v
        print(*a)
    
n = int(input())
a = input().split()
Isort(a,n)

Submission status: Wrong Answer

Solution code:
def Isort(a,n):
    for i in range(1,n):
        v = a[i]
        j = i-1
        while(j>=0 and a[j]>v):
            a[j+1] = a[j]
            j-=1
        a[j+1] = v
        print(*a)
    
n = int(input())
a = input().split()
print(*a)
Isort(a,n)

Submission status: Wrong Answer

Solution code:
def Isort(a,n):
    for i in range(1,n):
        v = a[i]
        j = i-1
        while(j>=0 and a[j]>v):
            a[j+1] = a[j]
            j-=1
        a[j+1] = v
        print(*a)
        
    
n = int(input())
a = input().split()
print(*a)
Isort(a,n)

Submission status: Wrong Answer

Solution code:
def trace(s):
    print " ".join(map(str,s))
    n = input()
    A = map(int, raw_input().split())
    if len(A) != n: exit()
    trace(A)
    for i in xrange(1, n):
        key = A[i]
        j = i - 1
        while j >= 0 and A[j] > key:
            A[j+1] = A[j]
            j -= 1
            A[j+1] = key
            trace(A)

Submission status: Wrong Answer

Solution code:
a=[]
n=int(input())
a=input().strip().split(' ')
print(a)
for i in range(1,n):
	v=a[i]
	j=i-1
	while j>=0 and a[j]>v:
		a[j+1]=a[j]
		j=j-1
	a[j+1]=v
	print(a)

Submission status: Wrong Answer

Solution code:
a=[]
n=int(input())
a=input().strip().split(' ')
for i in range(n):
	v=a[i]
	j=i-1
	while j>=0 and a[j]>v:
		a[j+1]=a[j]
		j=j-1
	a[j+1]=v
	print(a)

Submission status: Wrong Answer

Solution code:
a=[]
n=int(input())
a=input().strip().split(' ')
print(a)
for i in range(1,n):
	v=a[i]
	j=i-1
	while j>=0 and a[j]>v:
		a[j+1]=a[j]
		j=j-1
	a[j+1]=v
	print(a)

Submission status: Wrong Answer

Solution code:
n=int(input())


def insertionSort(A,N):
    for i in range(1,N):
        v=A[i]
        j=i-1
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j=j-1
        A[j+1]=v
        for i in range(len(A)):
            if i!=len(A)-1:
                print(A[i],end=' ')
            else :
                print(A[i])



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

Submission status: Wrong Answer

Solution code:
n=int(input())

list=list(map(int,input().split()))
for i in range(1,n):
    v=list[i]
    j=i-1
    while j>=0 and list[j]>v:
        list[j+1]=list[j]
        j=j-1
        list[j+1]=v
    for i in range(len(list)):
        if i!=len(list)-1:
            print(list[i],end=' ')
        else :
            print(list[i])

Submission status: Wrong Answer

Solution code:
n=int(input())

list=list(map(int,input().split()))
for i in range(1,n):
    v=list[i]
    j=i-1
    while j>=0 and list[j]>v:
        list[j+1]=list[j]
        j=j-1
    list[j+1]=v
    for i2 in range(len(list)):
        if i2!=len(list)-1:
            print(list[i2],end=' ')
        else :
            print(list[i2])

Submission status: Wrong Answer

Solution code:
def print_tmp(a_li):
    t = ''
    for i in a_li:
        t += str(i) + ' '
    print(t)


n = int(input())
a = input()
A = [int(i) for i in a.split(' ')]
print_tmp(A)
for i in range(1, n-1):
    v = A[i]
    j = i -1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print_tmp(A)
print_tmp(A)

Submission status: Wrong Answer

Solution code:
def print_tmp(a_li):
    s = [str(a) for a in a_li]
    t = ' '.join(s)
    print(t)


n = int(input())
a = input()
A = [int(i) for i in a.split(' ')]
print_tmp(A)
for i in range(1, n-1):
    v = A[i]
    j = i -1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print_tmp(A)
print_tmp(A)

Submission status: Wrong Answer

Solution code:
def print_tmp(a_li):
    s = [str(a) for a in a_li]
    t = ' '.join(s)
    print(t)


n = int(input())
a = input()
A = [int(i) for i in a.split(' ')]
# print_tmp(A)
for i in range(1, n):
    v = A[i]
    j = i -1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print_tmp(A)
# print_tmp(A)

Submission status: Wrong Answer

Solution code:

a = int(input())
b = input()
c = b.split(' ')
print(c)
d = [int(i) for i in c] #cを文字列から数字に変えた
for i in range(1, a): 
    v = d[i]
    j = i-1
    while j >=0 and d[j] >v:
        d[j+1] = d[j]
        j -= 1
    d[j+1] = v
print(d)

Submission status: Wrong Answer

Solution code:
a=input()
n=input().split()
s=n.sort()
print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=input()
a=input().split()
for i in range(1, len(a)-1):
    v=a[i]
    j=i-1
    while j>=0 and a[j]>v:
        a[j+1]=a[j]
        j-=1
        a[j+1]=v
print(a)

Submission status: Wrong Answer

Solution code:
n=input()
a=input().split()
for i in range(1, len(a)):
    v=a[i]
    j=i-1
    while j>=0 and a[j]>v:
        key=a[j+1]
        a[j+1]=a[j]
        j-=1
        a[j+1]=key
print(a)

Submission status: Wrong Answer

Solution code:
# -*- coding=utf-8 -*-
dummy = input()
list_ = list(map(int, input().split(" ")))

for i in range(1, len(list_)):
    while i > 0 and list_[i] < list_[i - 1]:
        list_[i], list_[i - 1] = list_[i - 1], list_[i]
        i = i - 1
    print(" ".join(list(map(str, list_))))

Submission status: Wrong Answer

Solution code:

def InsertionSort(l):
    for idx in range(1, len(l)):
        jdx = idx - 1
        while jdx >= 0 and l[idx] < l[jdx]:
            l[jdx], l[idx] = l[idx], l[jdx]
            idx -= 1
            jdx -= 1

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

def main():
    in_list = list(map(int, input().split(' ')))

    InsertionSort(in_list)


main()

Submission status: Wrong Answer

Solution code:

def InsertionSort(l):
    for idx in range(1, len(l)):
        jdx = idx - 1
        while jdx >= 0 and l[idx] < l[jdx]:
            l[jdx], l[idx] = l[idx], l[jdx]
            idx -= 1
            jdx -= 1

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

def main():
    _ = input()
    in_list = list(map(int, input().split(' ')))

    InsertionSort(in_list)


main()

Submission status: Wrong Answer

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

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

for i in range(0, N):
    v = A[i]
    j = i
    while (j >= 0) and (A[j] > j):
        A[j + 1], A[j] = A[j], v
        j -= 1

    for k in range(N):
        print('{0} '.format(A[k]), end='')
    print()

Submission status: Wrong Answer

Solution code:
num = input()
num = int(num)

strs = input()
list_str = strs.split(" ")
list_int = [int(s) for s in list_str]

for i in range(1, num):
    value = list_int[i]
    j = i - 1
    while j >= 0 and list_int[j] > value:
        list_int[j+1] = list_int[j]
        j -= 1
    list_int[j+1] = value
    print(' '.join(map(str,list_int)))

Submission status: Wrong Answer

Solution code:

if __name__ == "__main__":
    # 挿入ソート
    n = int(input())
    l = list(map(int, input().split()))
    for i in range(1, n):
        v = l[i]
        j = i - 1
        while j >= 0 and l[j] > v:
            l[j+1] = l[j]
            j -= 1
        l[j+1] = v
        print(l)

Submission status: Wrong Answer

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

def insertion_sort(array, n):
    print(array)
    for i in range(1,n):
        v = array[i]
        j = i-1
        while(j>=0 and array[j] > v):
            array[j+1] = array[j]
            j -= 1
        array[j+1] = v
        print(array)


insertion_sort(ary, N)

Submission status: Wrong Answer

Solution code:
"""
挿入ソート
"""
def insertion_sort(args):
    results = []
    for i in range(0, len(args)):
        v = args[i]
        j = i - 1
        while (j >= 0 and args[j] > v):
            args[j+1] = args[j]
            j -= 1
        args[j+1] = v
        results.append(args[:])
    return results

if __name__ == '__main__':
    n = int(input())
    args = list(map(int, input().split()))[0:n]
    results = insertion_sort(args)
    for result in results:
        print(result)

Submission status: Wrong Answer

Solution code:
def insertion_sort(l):
    for i in range(1, len(l)):
        tmp = l[i]
        j = i - 1
        while j >= 0 and l[j] > tmp:
            l[j+1] = l[j]
            j -= 1
        l[j+1] = tmp
        print(' '.join(map(str, l)))
    return l



if __name__ == '__main__':
    N = int(input())
    l = list(map(int, input().split()))

    insertion_sort(l)

Submission status: Wrong Answer

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

print(A)

for i in range(1,n):
    v=A[i]
    j=i-1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j=j-1
    A[j+1]=v
    print(A)

Submission status: Wrong Answer

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

print(A)

for i in range(1,n):
    v=A[i]
    j=i-1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j=j-1
    A[j+1]=v
    print(*A)

Submission status: Wrong Answer

Solution code:
def BS(A, N):
    A = list(map(int, A.split()))
    flag = 1
    count = 0 
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                unk = A[j]
                A[j] = A[j-1]
                A[j-1] = unk
                flag = 1
                count = count +1
    print(" ".join(map(str,A)))
    print(count)

Submission status: Wrong Answer

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

for i in range(1,N):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j + 1] = a[j]
        j-=1
        a[j + 1] = v
    print(' '.join(map(str,a)))

Submission status: Wrong Answer

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

for i in range(1,N):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j + 1] = a[j]
        j-=1
        a[j + 1] = v
    print(' '.join(map(str,a)))
print()

Submission status: Wrong Answer

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

for i in range(1,N):
    print(' '.join(map(str,a)))
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j + 1] = a[j]
        j-=1
        a[j + 1] = v

print()

Submission status: Wrong Answer

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

for i in range(1,N):
    print(' '.join(map(str,a)))
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j + 1] = a[j]
        j-=1
        a[j + 1] = v

Submission status: Wrong Answer

Solution code:
def insert():
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print_A()
        
def print_A():
    for i, n in enumerate(A):
        if i == N - 1:
            print(n)
        else:
            print(n, end=' ')

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

Submission status: Wrong Answer

Solution code:
def print_A():
    for i, n in enumerate(A):
        if i == N - 1:
            print(n)
        else:
            print(n, end=' ')

def insert():
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print_A()

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

Submission status: Wrong Answer

Solution code:
def insertion_sort(a, n):
    for i in range(1, n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j + 1] = a[j]
            j -= 1
        a[j + 1] = v
        print(a)


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

print(a)
insertion_sort(a, n)

Submission status: Wrong Answer

Solution code:
A = [int(a) for a in input().split()]
for i in range(1,len(A)):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(A)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = input().split()
y=[]
for i in range(n):
    y += [int(x[i])]
print(y)

for i in range(1,n):
    v = y[i]
    j = i-1
    while j >= 0 and y[j] > v:
        y[j+1] = y[j]
        j -= 1
    y[j+1] = v
    print(y)

Submission status: Wrong Answer

Solution code:
# coding = utf-8


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

for i in range(1, N):
    v = A[i]
    j = i-1
    while(j >= 0 and A[j] > v):
        A[j+1] = A[j]
        j = j-1
        A[j+1] = v
    print(A)

Submission status: Wrong Answer

Solution code:
# coding = utf-8
N = int(input())
A = [int(i) for i in input().split()]

for i in range(1, N):
    v = A[i]
    j = i-1
    while(j >= 0 and A[j] > v):
        A[j+1] = A[j]
        j = j-1
        A[j+1] = v

    for k in A:
        print(k, end=" ")
    print()

Submission status: Wrong Answer

Solution code:
# coding = utf-8


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

for i in range(1, N):
    v = A[i]
    j = i-1
    while(j >= 0 and A[j] > v):
        A[j+1] = A[j]
        j = j-1
        A[j+1] = v

    for k in A:
        print(k, end=" ")
    if i != N-1:    
        print()

Submission status: Wrong Answer

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

for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v

    print(A)

Submission status: Wrong Answer

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

for i in range(1, N):
    print(' '.join(map(str, A)))

    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v

Submission status: Wrong Answer

Solution code:
from sys import stdin
def stdinput():
    return stdin.readline().strip()

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

    for i in range(1, n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j + 1] = v
        print(' '.join(map(str, a)))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


for i in range(1, N):
    v = L[i]
    j = i - 1
    while j >= 0 and L[j] > v:
        L[j + 1] = L[j]
        j -= 1
    L[j + 1] = v
    print(' '.join(map(str, L)))

Submission status: Wrong Answer

Solution code:
l=input().split()
for i in range(1,len(l)):
    key = l[i]
    j = i -1
    while j>=0 and l[j]>key:
        l[j+1] = l[j]
        j-=1
        l[j+1] = key
    print(l)

Submission status: Wrong Answer

Solution code:
m=input()
l=input().split()
for i in range(1,len(l)):
    key = l[i]
    j = i -1
    while j>=0 and l[j]>key:
        l[j+1] = l[j]
        j-=1
        l[j+1] = key
    print(l)

Submission status: Wrong Answer

Solution code:
m=input()
l=input().split()
for i in range(1,len(l)):
    key = l[i]
    j = i -1
    while j>=0 and l[j]>key:
        l[j+1] = l[j]
        j-=1
        l[j+1] = key
    for k in range(0,len(l)):
        print (l[k],end=' ')
    print()

Submission status: Wrong Answer

Solution code:
m=input()
l=input().split()
for i in range(1,len(l)):
    key = l[i]
    j = i -1
    while j>=0 and l[j]>key:
        l[j+1] = l[j]
        j-=1
        l[j+1] = key
    for k in range(0,len(l)-1):
        print (l[k],end=' ')
    print(l[k+1])

Submission status: Wrong Answer

Solution code:
m=input()
l=input().split()
for i in range(1,len(l)):
    for k in range(0,len(l)-1):
            print (l[k],end=' ')
    print(l[k+1])
    key = l[i]
    j = i -1
    while j>=0 and l[j]>key:
        l[j+1] = l[j]
        j-=1
        l[j+1] = key
for k in range(0,len(l)-1):
    print (l[k],end=' ')
print(l[k+1])

Submission status: Wrong Answer

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


if __name__ == '__main__':
    for i in range(1, N):
        for j in range(N):
            if A[i] < A[j]:
                tmp_num = A[i]
                A[i] = A[j]
                A[j] = tmp_num
        print(A)

Submission status: Wrong Answer

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

if __name__ == '__main__':
    print(A)
    for i in range(1, N):
        for j in range(N):
            if A[i] < A[j]:
                tmp_num = A[i]
                A[i] = A[j]
                A[j] = tmp_num
                break
        print(A)

Submission status: Wrong Answer

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

if __name__ == '__main__':
    print(A)
    for i in range(1, N):
        for j in range(N):
            if A[i] < A[j]:
                tmp_num = A[i]
                A[i] = A[j]
                A[j] = tmp_num
        print(A)

Submission status: Wrong Answer

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

if __name__ == '__main__':
    print(A)
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
            A[j+1] = v
        print(A)

Submission status: Wrong Answer

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

if __name__ == '__main__':
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
            A[j+1] = v
        print(A)

Submission status: Wrong Answer

Solution code:
intMax = -100000000

Submission status: Wrong Answer

Solution code:
intMax = -100000000
inputData = int(input())
inputList = list()

Submission status: Wrong Answer

Solution code:
intMax = -100000000
inputData = int(input())
inputList = list()
count = 0

Submission status: Wrong Answer

Solution code:
intMax = -100000000
inputData = int(input())
inputList = list()
count = 0
while count < inputData:
    count = count + 1

Submission status: Wrong Answer

Solution code:
intMax = -100000000
inputData = int(input())
inputList = list()
count = 0

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(' '.join([str(a) for a in A]))

def run():
    N = int(input())
    A = [int(i) for i in input().split()]
    insertionSort(A,N)

if __name__ == '__main__':
    run()

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        print(' '.join([str(a) for a in A]))
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(' '.join([str(a) for a in A]))

def run():
    N = int(input())
    A = [int(i) for i in input().split()]
    insertionSort(A,N)

if __name__ == '__main__':
    run()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    print("----------")
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
        print(*A)
    A[j+1] = v
print(*A)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(*A)
print(*A)

Submission status: Wrong Answer

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

if __name__ == '__main__':
    print(A)
    for i in range(1, N):
        target_num = A[i]
        for j in range(i):
            if A[j] > target_num:
                tmp_idx = i
                while j < tmp_idx:
                    A[tmp_idx] = A[tmp_idx-1]
                    tmp_idx -= 1
                A[j] = target_num
                break
        print(A)

Submission status: Wrong Answer

Solution code:
def insertionSort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1

        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1

        A[j + 1] = v

        print(" ".join(list(map(str, A))))

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

    insertionSort(A, N)

main()

Submission status: Wrong Answer

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

print(A)

for i in range(1, n):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    print(A)

Submission status: Wrong Answer

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

    print(A)

    for i in range(1, n):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        print(A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def printA( A, n ):
    for i in range(n):
        print( A[i], end=' ' )
    print()

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

    for i in range(1, n):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        printA(A, n)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def printA( A, n ):
    for i in range(n):
        print( A[i], end=' ' )
    print()

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

    for i in range(1, n):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        printA(A, n)
    return 0

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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



for i in range(N):
    v = b[i]
    j = i-1
    while j>=0 and b[j]>v:
        b[j+1] = b[j]
        j = j-1
        b[j+1] = v
    print(a)

Submission status: Wrong Answer

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



for i in range(N):
    v = b[i]
    j = i-1
    while j>=0 and b[j]>v:
        b[j+1] = b[j]
        j = j-1
        b[j+1] = v
    print(b)

Submission status: Wrong Answer

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



for i in range(N):
    v = b[i]
    j = i-1
    while j>=0 and b[j]>v:
        b[j+1] = b[j]
        j = j-1
        b[j+1] = v
    b = [str(n) for n in a]
    print(" ".join(b))

Submission status: Wrong Answer

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



for i in range(N):
    v = b[i]
    j = i-1
    while j>=0 and b[j]>v:
        b[j+1] = b[j]
        j = j-1
        b[j+1] = v
    b = [str(n) for n in b]
    print(" ".join(b))

Submission status: Wrong Answer

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

for j in range(1, n):
    key = x[j]
    for i in range(j)[::-1]:
        if x[i] > key:
            x[i+1] = x[i]
        else:
            i += 1
            break
    else:
        i = 0
    x[i] = key
    
    for e in x:
        print e,
    print

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#from __future__ import print_function
import time
import sys
import io
import re
import math
i = 0
N=int(raw_input())
l=map(int, raw_input().split())

for j in range(1,len(l)):
    key=l[j]
    i=j-1
    while i>=0 and l[i] > key:
       l[i+1]=l[i]
       i-=1
    l[i+1]=key
    print ' '.join(map(str, l))

Submission status: Wrong Answer

Solution code:
n = input()
a = map(int, raw_input().split())
for j in range(1, len(a)):
	key = a[j]
	i = j - 1
	while (i > -1) and (a[i] > key):
		a[i+1] = a[i]
		i = i - 1
	a[i+1] = key
	print ' '.join(map(str, a))

Submission status: Wrong Answer

Solution code:
n = input()
A = raw_input().split()
for j in range(1,n):
    key = A[j]
    # insert A[j] into the sorted sequence A[1,...,j-1]
    i = j - 1
    while i > -1 and A[i] > key:
       A[i+1] = A[i]
       i = i - 1
    A[i+1] = key
    print A

Submission status: Wrong Answer

Solution code:
n = input()
A = map(int,raw_input().split())
print A
for j in range(1,n):
    key = A[j]
    # insert A[j] into the sorted sequence A[1,...,j-1]
    i = j - 1
    while i >= 0 and A[i] > key:
       A[i+1] = A[i]
       i -= 1
    A[i+1] = key
    print A