s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s568204099 | p02262 | u839008951 | 1516432515 | Python | Python3 | py | Runtime Error | 5970 | 10616 | 608 | import copy
cnt = 0
def insSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
def shellSort(A, n):
G = []
i = 1
while True:
G.appe... |
s678479000 | p02262 | u839008951 | 1516432734 | Python | Python3 | py | Runtime Error | 6140 | 10616 | 608 | import copy
cnt = 0
def insSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
def shellSort(A, n):
G = []
i = 1
while True:
G.appe... |
s225034507 | p02262 | u088372268 | 1517624891 | Python | Python3 | py | Runtime Error | 4020 | 16000 | 502 | n, gap = int(input()), []
data = list(map(int, [input() for i in range(n)]))
cnt, g = 0, n
while g >= 1:
g //= 2
gap.append(g)
if gap[0]:
gap.remove(0)
m = len(gap)
for i in range(m):
for idx in range(gap[i], n):
j = idx - gap[i]
while j >= 0 and data[j] > data[j+gap[i]]:
dat... |
s355233652 | p02262 | u088372268 | 1517625088 | Python | Python3 | py | Runtime Error | 3840 | 16000 | 502 | n, gap = int(input()), []
data = list(map(int, [input() for i in range(n)]))
cnt, g = 0, n
while g >= 1:
g //= 2
gap.append(g)
if gap[0]:
gap.remove(0)
m = len(gap)
for i in range(m):
for idx in range(gap[i], n):
j = idx - gap[i]
while j >= 0 and data[j] > data[j+gap[i]]:
dat... |
s299944848 | p02262 | u088372268 | 1517625255 | Python | Python3 | py | Runtime Error | 3900 | 16008 | 473 | n, gap = int(input()), []
data = list(map(int, [input() for i in range(n)]))
cnt, g = 0, n
while g >= 1:
g //= 2
gap.append(g)
m = len(gap)
for i in range(m):
for idx in range(gap[i], n):
j = idx - gap[i]
while j >= 0 and data[j] > data[j+gap[i]]:
data[j+gap[i]], data[j] = data[j... |
s780435990 | p02262 | u088372268 | 1517625674 | Python | Python3 | py | Runtime Error | 3260 | 16008 | 473 | n, gap = int(input()), []
data = list(map(int, [input() for i in range(n)]))
cnt, g = 0, n
while g >= 1:
g //= 2
gap.append(g)
m = len(gap)
for i in range(m):
gi = gap[i]
for idx in range(gap[i], n):
j = idx - gap[i]
while j >= 0 and data[j] > data[j+gi]:
data[j+gi], data[j] ... |
s199021317 | p02262 | u088372268 | 1517629306 | Python | Python3 | py | Runtime Error | 3280 | 16004 | 438 | n, gap = int(input()), []
data = list(map(int, [input() for i in range(n)]))
cnt, g = 0, n
while g >= 1:
g //= 2
gap.append(g)
m = len(gap)
for i in gap:
for idx in range(i, n):
j = idx - i
while j >= 0 and data[j] > data[j+i]:
data[j+i], data[j] = data[j], data[j+i]
... |
s211904694 | p02262 | u088372268 | 1517633232 | Python | Python3 | py | Runtime Error | 2930 | 16004 | 490 | n, gap = int(input()), []
data = list(map(int, [input() for i in range(n)]))
cnt, g = 0, 0
while g <= n//9:
g = 3 * g + 1
gap.append(g)
m = len(gap)
gap = [gap[i] for i in range(m-1, -1, -1)]
for i in gap:
for idx in range(i, n):
j = idx - i
while j >= 0 and data[j] > data[j+i]:
... |
s903384464 | p02262 | u088372268 | 1517641520 | Python | Python3 | py | Runtime Error | 3100 | 16004 | 490 | n, gap = int(input()), []
data = list(map(int, [input() for i in range(n)]))
cnt, g = 0, 0
while g <= n//9:
g = 3 * g + 1
gap.append(g)
m = len(gap)
gap = [gap[i] for i in range(m-1, -1, -1)]
for i in gap:
for idx in range(i, n):
j = idx - i
while j >= 0 and data[j] > data[j+i]:
... |
s709072672 | p02262 | u547838013 | 1517667023 | Python | Python3 | py | Runtime Error | 3000 | 16008 | 489 | n, gap = int(input()), []
data = list(map(int, [input() for i in range(n)]))
cnt, g = 0, 0
while g <= n//9:
g = 3 * g + 1
gap.append(g)
m = len(gap)
gap = [gap[i] for i in range(m-1, -1, -1)]
for i in gap:
for idx in range(i, n):
j = idx - i
while j >= 0 and data[j] > data[j+i]:
... |
s949283832 | p02262 | u996463517 | 1518250198 | Python | Python3 | py | Runtime Error | 1350 | 9836 | 606 | def shellSort(A):
global cnt
cnt = 0
h = 1
g = []
while h <= len(A):
g.append(h)
h = 3*h+1
g.reverse()
m = len(g)
print(m)
print(' '.join(map(str,g)))
for i in range(m):
insertionSort(A,g[i])
def insertionSort(A,g):
global cnt
for i in range... |
s082095761 | p02262 | u996463517 | 1518250365 | Python | Python3 | py | Runtime Error | 1340 | 9836 | 618 | def insertionSort(A,g):
global cnt
for i in range(g,len(A)):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
def shellSort(A):
global cnt
cnt = 0
h = 1
g = []
w... |
s345268681 | p02262 | u150984829 | 1518270678 | Python | Python3 | py | Runtime Error | 2320 | 10352 | 255 | n=int(input())
s=[1]
c=0
while s[-1]*3<n:s+=[s[-1]*3+1]
s=s[::-1]
a=[int(input())for _ in[0]*n]
for g in s:
for i in range(n):
k=a[i]
j=i-g
while j>=0 and a[j]>k:a[j+g]=a[j];j-=g;c+=1
a[j+g]=k
print(len(s))
print(*s)
print(c)
for x in a:print(x)
|
s093704838 | p02262 | u150984829 | 1518271178 | Python | Python3 | py | Runtime Error | 2300 | 10712 | 256 | n=int(input())
a=[int(input())for _ in[0]*n]
s=[1]
c=0
while s[-1]*3<n:s+=[s[-1]*3+1]
s=s[::-1]
for g in s:
for i in range(g,n):
v=a[i]
j=i-g
while j>=0 and a[j]>v:a[j+g]=a[j];j-=g;c+=1
a[j+g]=v
print(len(s))
print(*s)
print(c)
print(*a,sep='\n')
|
s841201715 | p02262 | u150984829 | 1518271388 | Python | Python3 | py | Runtime Error | 2350 | 10716 | 254 | n=int(input())
a=[int(input())for _ in[0]*n]
s=[1]
c=0
while s[-1]*3<n:s+=[s[-1]*3+1]
s=s[::-1]
for g in s:
for i in range(n):
v=a[i]
j=i-g
while j>=0 and a[j]>v:a[j+g]=a[j];j-=g;c+=1
a[j+g]=v
print(len(s))
print(*s)
print(c)
print(*a,sep='\n')
|
s901182524 | p02262 | u150984829 | 1518271615 | Python | Python3 | py | Runtime Error | 2360 | 10712 | 254 | n=int(input())
a=[int(input())for _ in[0]*n]
s=[1]
c=0
while s[-1]*3<n:s+=[s[-1]*3+1]
s=s[::-1]
for g in s:
for i in range(n):
v=a[i]
j=i-g
while j>=0 and a[j]>v:a[j+g]=a[j];j-=g;c+=1
a[j+g]=v
print(len(s))
print(*s)
print(c)
print(*a,sep='\n')
|
s310213962 | p02262 | u150984829 | 1518272071 | Python | Python3 | py | Runtime Error | 1840 | 10712 | 304 | n=int(input())
a=[int(input())for _ in[0]*n]
s=[int(pow(4, i) + 3*pow(2, i-1) + 1) for i in range(13)[::-1]] + [1]
s=[v for v in s if v <= n]
c=0
for g in s:
for i in range(n):
v=a[i]
j=i-g
while j>=0 and a[j]>v:a[j+g]=a[j];j-=g;c+=1
a[j+g]=v
print(len(s))
print(*s)
print(c)
print(*a,sep='\n')
|
s302053204 | p02262 | u150984829 | 1518272295 | Python | Python3 | py | Runtime Error | 2390 | 10716 | 313 | # Runtime Error
n=int(input())
a=[int(input())for _ in[0]*n]
s=[797161,265720,88573,29524,9841,3280,1093,364,121,40,13,4,1]
s=[v for v in s if v <= n]
c=0
for g in s:
for i in range(n):
v=a[i]
j=i-g
while j>=0 and a[j]>v:a[j+g]=a[j];j-=g;c+=1
a[j+g]=v
print(len(s))
print(*s)
print(c)
print(*a,sep='\n')
|
s789401657 | p02262 | u150984829 | 1518274043 | Python | Python3 | py | Runtime Error | 2330 | 10624 | 410 | n = int(input())
A = [int(input()) for _ in range(n)]
cnt = 0
G = [797161,265720,88573,29524,9841,3280,1093,364,121,40,13,4,1]
G = [v for v in G if v <= n]
m = len(G)
for g in G:
for i in range(n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
... |
s312397683 | p02262 | u150984829 | 1518274537 | Python | Python3 | py | Runtime Error | 0 | 0 | 480 | import sys
n = int(input())
A=[int(e)for e in sys.stdin]
cnt = 0
G = [797161,265720,88573,29524,9841,3280,1093,364,121,40,13,4,1]
G = [v for v in G if v <= n]
def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A... |
s641597779 | p02262 | u150984829 | 1518274668 | Python | Python3 | py | Runtime Error | 0 | 0 | 424 | import sys
n = int(input())
A=[int(e)for e in sys.stdin]
cnt = 0
G = [797161,265720,88573,29524,9841,3280,1093,364,121,40,13,4,1]
G = [v for v in G if v <= n]
for g in G:
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
... |
s274202420 | p02262 | u150984829 | 1518274679 | Python | Python3 | py | Runtime Error | 2330 | 10636 | 409 | import sys
n = int(input())
A=[int(e)for e in sys.stdin]
cnt = 0
G = [797161,265720,88573,29524,9841,3280,1093,364,121,40,13,4,1]
G = [v for v in G if v <= n]
for g in G:
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
... |
s079788836 | p02262 | u088372268 | 1518653983 | Python | Python3 | py | Runtime Error | 2940 | 15976 | 471 | import sys
n, gap = int(input()), []
data = [int(i) for i in sys.stdin.readlines()]
cnt, g = 0, 0
while g <= n//9:
g = 3 * g + 1
gap.append(g)
m = len(gap)
gap = gap[::-1]
for i in gap:
for idx in range(i, n):
j = idx - i
while j >= 0 and data[j] > data[j+i]:
data[j+i], data[j] ... |
s116218040 | p02262 | u088372268 | 1518654312 | Python | Python3 | py | Runtime Error | 2920 | 16004 | 463 | n, gap = int(input()), []
data = list(map(int, [input() for i in range(n)]))
cnt, g = 0, 0
while g <= n//9:
g = 3 * g + 1
gap.append(g)
m = len(gap)
gap = gap[::-1]
for i in gap:
for idx in range(i, n):
j = idx - i
while j >= 0 and data[j] > data[j+i]:
data[j+i], data[j] = data[j... |
s878729437 | p02262 | u088372268 | 1518654446 | Python | Python3 | py | Runtime Error | 3040 | 15980 | 471 | import sys
n, gap = int(input()), []
data = [int(i) for i in sys.stdin.readlines()]
cnt, g = 0, 0
while g <= n//9:
g = 3 * g + 1
gap.append(g)
m = len(gap)
gap = gap[::-1]
for i in gap:
for idx in range(i, n):
j = idx - i
while j >= 0 and data[j] > data[j+i]:
data[j+i], data[j] ... |
s933446982 | p02262 | u088372268 | 1518658342 | Python | Python3 | py | Runtime Error | 2190 | 15980 | 487 | import sys
n, gap = int(input()), []
data = [int(i) for i in sys.stdin.readlines()]
cnt, g = 0, 0
while g <= n//9:
g = 3 * g + 1
gap.append(g)
m = len(gap)
gap = gap[::-1]
for i in gap:
for idx in range(i, n):
j = idx - i
v = data[idx]
while j >= 0 and data[j] > v:
data[... |
s438793484 | p02262 | u150984829 | 1519781958 | Python | Python3 | py | Runtime Error | 0 | 0 | 468 | import sys
n = int(input())
A = [int(e)for e in sys.stdin]
cnt = 0
G = [int((2.25**i-1)/1.25)for i in range(17,0,-1)]
G = [v for v in G if v <= n]
def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
... |
s694061025 | p02262 | u150984829 | 1519865757 | Python | Python3 | py | Runtime Error | 0 | 0 | 611 | import sys
def solve():
n = int(input())
A = list(map(int,sys.stdin))
cnt = 0
G = [int((2.25**i-1)/1.25)for i in range(17,0,-1)]
G = [v for v in G if v <= n]
def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while ... |
s787031607 | p02262 | u613534067 | 1520737734 | Python | Python3 | py | Runtime Error | 1220 | 9896 | 709 | import math
cnt = 0
m = 0
g = []
def insertion_sort(a, n, g):
# cnt+=1 のときにローカルスコープの外を見にいくようにするため
global cnt
for i in range(g, n):
v = a[i]
k = i - g
while k >= 0 and a[k] > v:
a[k+g] = a[k]
k -= g
cnt += 1
a[k+g] = v
def shell_sort(a, n):
... |
s383008551 | p02262 | u613534067 | 1520738078 | Python | Python3 | py | Runtime Error | 1320 | 9896 | 709 | import math
cnt = 0
m = 0
g = []
def insertion_sort(a, n, g):
# cnt+=1 のときにローカルスコープの外を見にいくようにするため
global cnt
for i in range(g, n):
v = a[i]
k = i - g
while k >= 0 and a[k] > v:
a[k+g] = a[k]
k -= g
cnt += 1
a[k+g] = v
def shell_sort(a, n):
... |
s975530428 | p02262 | u605879293 | 1522648611 | Python | Python3 | py | Runtime Error | 0 | 0 | 467 |
def shellSort(array, G):
cnt = 0
flag = False
for g in G:
if g != G[-1]:
insertionSort(array, g, cnt, flag)
else:
flag = True
insertionSort(array, g, cnt, flag)
n = int(input())
array = []
for i in range(n):
array.append(int(input()))
G = [4, 1]
p... |
s029295348 | p02262 | u605879293 | 1522650738 | Python | Python3 | py | Runtime Error | 1250 | 9832 | 644 | def insertionSort(array, g):
global cnt
n = len(array)
for i in range(g, n):
v = array[i]
j = i - g
while j >= 0 and array[j] > v:
array[j+g] = array[j]
j = j - g
cnt += 1
array[j+g] = v
def shellSort(array, G):
global cnt
cnt = 0... |
s689208094 | p02262 | u605879293 | 1522651563 | Python | Python3 | py | Runtime Error | 1340 | 9828 | 618 | def insertionSort(array, g):
global cnt
n = len(array)
for i in range(g, n):
v = array[i]
j = i - g
while j >= 0 and array[j] > v:
array[j+g] = array[j]
j = j - g
cnt += 1
array[j+g] = v
def shellSort(array, G):
global cnt
cnt = 0... |
s282682400 | p02262 | u605879293 | 1522652043 | Python | Python3 | py | Runtime Error | 1340 | 10628 | 594 | def insertionSort(array, g):
global cnt
n = len(array)
for i in range(g, n):
v = array[i]
j = i - g
while j >= 0 and array[j] > v:
array[j+g] = array[j]
j = j - g
cnt += 1
array[j+g] = v
def shellSort(array, G):
global cnt
cnt = 0... |
s173918456 | p02262 | u114315703 | 1523411650 | Python | Python3 | py | Runtime Error | 20 | 5616 | 617 | cnt = 0
def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
def shellSort(A, n):
global cnt
G = [i for i in reversed(range(1, len(A),... |
s395907936 | p02262 | u114315703 | 1523412226 | Python | Python3 | py | Runtime Error | 20 | 5616 | 634 | cnt = 0
def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
def shellSort(A, n):
global cnt
G = [i for i in reversed(range(1, len(A),... |
s160320813 | p02262 | u114315703 | 1523412663 | Python | Python3 | py | Runtime Error | 1320 | 9832 | 656 | cnt = 0
def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
def shellSort(A, n):
global cnt
G = []
v = 1
while v <= len(A):
... |
s754756854 | p02262 | u114315703 | 1523412738 | Python | Python3 | py | Runtime Error | 1270 | 9844 | 686 | cnt = 0
def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
def shellSort(A, n):
global cnt
G = []
v = 1
while v <= len(A):
... |
s182722236 | p02262 | u114315703 | 1523413382 | Python | Python3 | py | Runtime Error | 1260 | 9832 | 676 | cnt = 0
def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
def shellSort(A, n):
global cnt
G = []
v = 1
while v <= len(A):
... |
s616731861 | p02262 | u114315703 | 1523413564 | Python | Python3 | py | Runtime Error | 1330 | 9832 | 739 | cnt = 0
def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
def shellSort(A, n):
global cnt
G = []
v = 1
while v <= len(A):
... |
s751245437 | p02262 | u126478680 | 1524955808 | Python | Python3 | py | Runtime Error | 1290 | 11740 | 821 | #! python
# shell_sort.py
import copy
import math
count = 0
def insertion_sort(A, N, g):
global count
A_ = copy.copy(A)
for i in range(g, N):
v = A_[i]
j = i - g
while j >= 0 and A_[j] > v:
A_[j+g] = A_[j]
j = j - g
count += 1
A_[j + g] ... |
s010972739 | p02262 | u126478680 | 1524956093 | Python | Python3 | py | Runtime Error | 1450 | 10676 | 744 | #! python
# shell_sort.py
import copy
import math
count = 0
def insertion_sort(A, N, g):
global count
for i in range(g, N):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
count += 1
A[j + g] = v
# h_(i+1) = 3h_i + 1 が... |
s402149631 | p02262 | u255317651 | 1524968569 | Python | Python3 | py | Runtime Error | 0 | 0 | 719 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 10:42:20 2018
ALDS1-2d
@author: maezawa
"""
import numpy as np
def insertion(a, n, g):
global cnt
for i in range(g, n):
v = a[i]
j = i-g
while j>=0 and a[j]>v:
a[j+g] = a[j]
j = j - g
cnt += 1
... |
s682264956 | p02262 | u255317651 | 1524968791 | Python | Python3 | py | Runtime Error | 30 | 5688 | 706 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 10:42:20 2018
ALDS1-2d
@author: maezawa
"""
import math
def insertion(a, n, g):
global cnt
for i in range(g, n):
v = a[i]
j = i-g
while j>=0 and a[j]>v:
a[j+g] = a[j]
j = j - g
cnt += 1
a[j+g] ... |
s892368019 | p02262 | u255317651 | 1524969135 | Python | Python3 | py | Runtime Error | 20 | 5684 | 706 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 10:42:20 2018
ALDS1-2d
@author: maezawa
"""
import math
def insertion(a, n, g):
global cnt
for i in range(g, n):
v = a[i]
j = i-g
while j>=0 and a[j]>v:
a[j+g] = a[j]
j = j - g
cnt += 1
a[j+g] ... |
s448862411 | p02262 | u255317651 | 1524969174 | Python | Python3 | py | Runtime Error | 20 | 5688 | 706 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 10:42:20 2018
ALDS1-2d
@author: maezawa
"""
import math
def insertion(a, n, g):
global cnt
for i in range(g, n):
v = a[i]
j = i-g
while j>=0 and a[j]>v:
a[j+g] = a[j]
j = j - g
cnt += 1
a[j+g] ... |
s747519235 | p02262 | u255317651 | 1524969364 | Python | Python3 | py | Runtime Error | 4830 | 9916 | 754 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 10:42:20 2018
ALDS1-2d
@author: maezawa
"""
import math
def insertion(a, n, g):
global cnt
for i in range(g, n):
v = a[i]
j = i-g
while j>=0 and a[j]>v:
a[j+g] = a[j]
j = j - g
cnt += 1
a[j+g] ... |
s747492201 | p02262 | u255317651 | 1524972954 | Python | Python3 | py | Runtime Error | 1320 | 9912 | 936 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 10:42:20 2018
ALDS1-2d
@author: maezawa
"""
import math
def insertion(a, n, g):
global cnt
for i in range(g, n):
v = a[i]
j = i-g
while j>=0 and a[j]>v:
a[j+g] = a[j]
j = j - g
cnt += 1
a[j+g] ... |
s575628898 | p02262 | u255317651 | 1524973269 | Python | Python3 | py | Runtime Error | 1330 | 9908 | 935 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 10:42:20 2018
ALDS1-2d
@author: maezawa
"""
import math
def insertion(a, n, g):
global cnt
for i in range(g, n):
v = a[i]
j = i-g
while j>=0 and a[j]>v:
a[j+g] = a[j]
j = j - g
cnt += 1
a[j+g] ... |
s194509763 | p02262 | u255317651 | 1524973577 | Python | Python3 | py | Runtime Error | 1740 | 9912 | 935 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 10:42:20 2018
ALDS1-2d
@author: maezawa
"""
import math
def insertion(a, n, g):
global cnt
for i in range(g, n):
v = a[i]
j = i-g
while j>=0 and a[j]>v:
a[j+g] = a[j]
j = j - g
cnt += 1
a[j+g] ... |
s282649337 | p02262 | u255317651 | 1524974173 | Python | Python3 | py | Runtime Error | 1330 | 9848 | 924 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 10:42:20 2018
ALDS1-2d
@author: maezawa
"""
def insertion(a, n, g):
global cnt
for i in range(g, n):
v = a[i]
j = i-g
while j>=0 and a[j]>v:
a[j+g] = a[j]
j = j - g
cnt += 1
a[j+g] = v
... |
s969010616 | p02262 | u255317651 | 1524976972 | Python | Python3 | py | Runtime Error | 1260 | 9848 | 925 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 10:42:20 2018
ALDS1-2d
@author: maezawa
"""
def insertion(a, n, g):
global cnt
for i in range(g, n):
v = a[i]
j = i-g
while j>=0 and a[j]>v:
a[j+g] = a[j]
j = j - g
cnt += 1
a[j+g] = v
... |
s245571074 | p02262 | u126478680 | 1525198411 | Python | Python3 | py | Runtime Error | 1210 | 9904 | 675 | import math
count = 0
m = 0
G = []
def insertion_sort(A, N, g):
global count
for i in range(g, N):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
count += 1
A[j + g] = v
# h_(i+1) = 3h_i + 1 が最良の間隔 (らしい)
def shell_sort... |
s873617401 | p02262 | u311299757 | 1525441984 | Python | Python3 | py | Runtime Error | 7380 | 11584 | 687 | from typing import List
def insertion_sort(arr: List[int], n: int, g: int):
cnt = 0
for i in range(g, n):
v = arr[i]
j = i - g
while (j >= 0 and arr[j] > v):
arr[j + g] = arr[j]
j = j - g
cnt += 1
arr[j + g] = v
return cnt
def shell_s... |
s024981415 | p02262 | u986478725 | 1527429941 | Python | Python3 | py | Runtime Error | 20 | 5608 | 1404 | # ALDS1_2_D.
# シェルソート。
# 理論上、h[i + 1] = h[i] + 1, h[0] = 1という数列が使えて、
# これによると計算量がO(n^1.25)くらいになるとか。
# 挿入ソートを間隔でメソッド化してcntを出力→加算、の流れ。
def show(a):
# 配列の中身を出力する。
_str = ""
for i in range(len(a) - 1):
_str += str(a[i]) + " "
_str += str(a[len(a) - 1])
print(_str)
def insertion_sort(a, g):
... |
s268707309 | p02262 | u986478725 | 1527430182 | Python | Python3 | py | Runtime Error | 1700 | 9848 | 1553 | # ALDS1_2_D.
# シェルソート。
# 理論上、h[i + 1] = h[i] + 1, h[0] = 1という数列が使えて、
# これによると計算量がO(n^1.25)くらいになるとか。
# 挿入ソートを間隔でメソッド化してcntを出力→加算、の流れ。
def show(a):
# 配列の中身を出力する。
_str = ""
for i in range(len(a) - 1):
_str += str(a[i]) + " "
_str += str(a[len(a) - 1])
print(_str)
def insertion_sort(a, g):
... |
s401090451 | p02262 | u986478725 | 1527431149 | Python | Python3 | py | Runtime Error | 1660 | 9844 | 1553 | # ALDS1_2_D.
# シェルソート。
# 理論上、h[i + 1] = h[i] + 1, h[0] = 1という数列が使えて、
# これによると計算量がO(n^1.25)くらいになるとか。
# 挿入ソートを間隔でメソッド化してcntを出力→加算、の流れ。
def show(a):
# 配列の中身を出力する。
_str = ""
for i in range(len(a) - 1):
_str += str(a[i]) + " "
_str += str(a[len(a) - 1])
print(_str)
def insertion_sort(a, g):
... |
s866256537 | p02262 | u986478725 | 1527431712 | Python | Python3 | py | Runtime Error | 1340 | 9848 | 1583 | # ALDS1_2_D.
# シェルソート。
# 理論上、h[i + 1] = h[i] + 1, h[0] = 1という数列が使えて、
# これによると計算量がO(n^1.25)くらいになるとか。
# 挿入ソートを間隔でメソッド化してcntを出力→加算、の流れ。
def show(a):
# 配列の中身を出力する。
_str = ""
for i in range(len(a) - 1):
_str += str(a[i]) + " "
_str += str(a[len(a) - 1])
print(_str)
def insertion_sort(a, g):
... |
s309743382 | p02262 | u986478725 | 1527432086 | Python | Python3 | py | Runtime Error | 0 | 0 | 1674 | # ALDS1_2_D.
# シェルソート。
# 理論上、h[i + 1] = h[i] + 1, h[0] = 1という数列が使えて、
# これによると計算量がO(n^1.25)くらいになるとか。
# 挿入ソートを間隔でメソッド化してcntを出力→加算、の流れ。
def show(a):
# 配列の中身を出力する。
_str = ""
for i in range(len(a) - 1):
_str += str(a[i]) + " "
_str += str(a[len(a) - 1])
print(_str)
def insertion_sort(a, g):
... |
s574646912 | p02262 | u986478725 | 1527432124 | Python | Python3 | py | Runtime Error | 1330 | 9844 | 1675 | # ALDS1_2_D.
# シェルソート。
# 理論上、h[i + 1] = h[i] + 1, h[0] = 1という数列が使えて、
# これによると計算量がO(n^1.25)くらいになるとか。
# 挿入ソートを間隔でメソッド化してcntを出力→加算、の流れ。
def show(a):
# 配列の中身を出力する。
_str = ""
for i in range(len(a) - 1):
_str += str(a[i]) + " "
_str += str(a[len(a) - 1])
print(_str)
def insertion_sort(a, g):
... |
s277106508 | p02262 | u986478725 | 1527432745 | Python | Python3 | py | Runtime Error | 1260 | 9840 | 1691 | # ALDS1_2_D.
# シェルソート。
# 理論上、h[i + 1] = h[i] + 1, h[0] = 1という数列が使えて、
# これによると計算量がO(n^1.25)くらいになるとか。
# 挿入ソートを間隔でメソッド化してcntを出力→加算、の流れ。
def show(a):
# 配列の中身を出力する。
_str = ""
for i in range(len(a) - 1):
_str += str(a[i]) + " "
_str += str(a[len(a) - 1])
print(_str)
def insertion_sort(a, g):
... |
s400786861 | p02262 | u684241248 | 1527432885 | Python | Python3 | py | Runtime Error | 0 | 0 | 655 | N = int(input())
ary = [int(input()) for _ in range(N)]
def insertion_sort(ary, g):
cnt = 0
for i in range(g, N):
v = ary[i]
j = i - g
while j >= 0 and ary[j] > v:
ary[j + g] = ary[j]
j -= g
cnt += 1
ary[j + g] = v
return cnt
def sh... |
s024684667 | p02262 | u684241248 | 1527432996 | Python | Python3 | py | Runtime Error | 0 | 0 | 687 | N = int(input())
ary = [int(input()) for _ in range(N)]
def insertion_sort(ary, g):
cnt = 0
for i in range(g, N):
v = ary[i]
j = i - g
while j >= 0 and ary[j] > v:
ary[j + g] = ary[j]
j -= g
cnt += 1
ary[j + g] = v
return cnt
def sh... |
s103647827 | p02262 | u303842929 | 1527746771 | Python | Python3 | py | Runtime Error | 0 | 0 | 1413 | #include <iostream>
#include <cstdlib>
#include <vector>
//shellSort(A, n) は、一定の間隔 g だけ離れた要素のみを対象とした挿入ソートである insertionSort(A, n, g) を、最初は大きい値から g を狭めながら繰り返します。これをシェルソートと言います。
//上の疑似コードの ? を埋めてこのプログラムを完成させてください。n と数列 A が与えられるので、疑似コード中の m、m 個の整数 Gi(i=0,1,...,m-1)、入力 Aを昇順にした列を出力するプログラムを作成してください。ただし、出力は以下の条件を満 たす必要があります。
... |
s063132333 | p02262 | u682153677 | 1528876894 | Python | Python3 | py | Runtime Error | 0 | 0 | 797 | # -*- coding: utf-8 -*-
def insertionSort(A, n, g):
cnt = 0
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j + g] = A[j]
j = j - g
cnt += 1
A[j + g] = v
print_line(A, cnt)
def shellSort(A, n):
m = 0
G = ... |
s057013120 | p02262 | u308033440 | 1528953849 | Python | Python3 | py | Runtime Error | 2560 | 13772 | 716 | def insertionSort(A,n,g):
for i in range(g,n,1):
v = int(A[i])
j = i - g
while j >= 0 and int(A[j]) > v:
global cnt
A[j + g] = A[j]
j = j - g
cnt = cnt + 1
A[j+g] = str(v)
def shellSort(A,n):
global cnt
global G
... |
s114017979 | p02262 | u308033440 | 1528953881 | Python | Python3 | py | Runtime Error | 2610 | 13772 | 716 | def insertionSort(A,n,g):
for i in range(g,n,1):
v = int(A[i])
j = i - g
while j >= 0 and int(A[j]) > v:
global cnt
A[j + g] = A[j]
j = j - g
cnt = cnt + 1
A[j+g] = str(v)
def shellSort(A,n):
global cnt
global G
... |
s843067894 | p02262 | u308033440 | 1528954834 | Python | Python3 | py | Runtime Error | 2520 | 13772 | 758 | def insertionSort(A,n,g):
for i in range(g,n,1):
v = int(A[i])
j = i - g
while j >= 0 and int(A[j]) > v:
global cnt
A[j + g] = A[j]
j = j - g
cnt = cnt + 1
A[j+g] = str(v)
def shellSort(A,n):
global cnt
global G
... |
s211672708 | p02262 | u308033440 | 1528954860 | Python | Python3 | py | Runtime Error | 2620 | 13772 | 758 | def insertionSort(A,n,g):
for i in range(g,n,1):
v = int(A[i])
j = i - g
while j >= 0 and int(A[j]) > v:
global cnt
A[j + g] = A[j]
j = j - g
cnt = cnt + 1
A[j+g] = str(v)
def shellSort(A,n):
global cnt
global G
... |
s505124495 | p02262 | u308033440 | 1528955177 | Python | Python3 | py | Runtime Error | 1260 | 10632 | 753 | def insertionSort(A,n,g):
for i in range(g,n,1):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
global cnt
A[j + g] = A[j]
j = j - g
cnt = cnt + 1
A[j+g] = v
def shellSort(A,n):
global cnt
global G
G = []
cnt... |
s940886091 | p02262 | u308033440 | 1528955195 | Python | Python3 | py | Runtime Error | 1240 | 10632 | 753 | def insertionSort(A,n,g):
for i in range(g,n,1):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
global cnt
A[j + g] = A[j]
j = j - g
cnt = cnt + 1
A[j+g] = v
def shellSort(A,n):
global cnt
global G
G = []
cnt... |
s305093587 | p02262 | u308033440 | 1528955230 | Python | Python3 | py | Runtime Error | 1300 | 10628 | 509 | def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
n = int(input())
A = [int(input()) for i in range(n)]
cnt = 0
G = [1]
for i in range(99):... |
s485785305 | p02262 | u308033440 | 1528955410 | Python | Python3 | py | Runtime Error | 1330 | 9828 | 521 | n = int(input())
a = []
for i in range(n):
a.append(int(input()))
def insertionsort(a, n, g):
global c
for i in range(g, n):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j + g] = a[j]
j = j - g
c += 1
a[j + g] = v
c = 0
g = [1]
while... |
s474200227 | p02262 | u308033440 | 1528955677 | Python | Python3 | py | Runtime Error | 2510 | 13772 | 716 | def insertionSort(A,n,g):
for i in range(g,n,1):
v = int(A[i])
j = i - g
while j >= 0 and int(A[j]) > v:
global cnt
A[j + g] = A[j]
j = j - g
cnt = cnt + 1
A[j+g] = str(v)
def shellSort(A,n):
global cnt
G = []
... |
s592275857 | p02262 | u308033440 | 1528955883 | Python | Python3 | py | Runtime Error | 0 | 0 | 772 | ef insert_sort(A, n, g, cnt):
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j -= g
cnt += 1
A[j+g] = v
return cnt
def shellSort(A, n):
cnt = 0
G = []; h = 0
while h <= n:
if 3 * h + 1 <=... |
s450442407 | p02262 | u657361950 | 1529371266 | Python | Python3 | py | Runtime Error | 0 | 0 | 797 | import sys
def print_arr(arr):
for i in range(len(arr)):
sys.stdout.write(str(arr[i]))
if i != len(arr) - 1:
sys.stdout.write(' ')
print()
def insertion_sort(arr, n, g):
cnt = 0
for i in range(g, n):
v = arr[i]
j = i - g
while j >= 0 and arr[j] > v:
arr[j + g] = arr[j]
j = j - g
cnt += 1
a... |
s498251412 | p02262 | u424720817 | 1529387688 | Python | Python3 | py | Runtime Error | 0 | 0 | 774 | def main():
n = int(input())
numbers = [int(input()) for i in range(n)]
count = shellSort(numbers, n)
print(count)
[print(i) for i in numbers]
def shellSort(numbers, n):
count = 0
m = 1
g = []
while m <= n :
g.append(m)
m = 3 * m + 1
for i in range(len(g), -1, ... |
s127440653 | p02262 | u298224238 | 1529471776 | Python | Python3 | py | Runtime Error | 0 | 0 | 645 | def insertionSort(arr, g):
cnt = 0
for i in range(g, len(arr)):
tmp = arr[i]
j = i - g
while(j >= 0 and arr[j] > tmp):
arr[j + g] = arr[j]
j -= g
cnt += 1
arr[j + 1] = tmp
return cnt
def shellSort(arr):
cnt = 0
g = []
h = 0
... |
s156411519 | p02262 | u298224238 | 1529471816 | Python | Python3 | py | Runtime Error | 0 | 0 | 647 | def insertionSort(arr, g):
cnt = 0
for i in range(g, len(arr)):
tmp = arr[i]
j = i - g
while(j >= 0 and arr[j] > tmp):
arr[j + g] = arr[j]
j -= g
cnt += 1
arr[j + 1] = tmp
return cnt
def shellSort(arr):
cnt = 0
g = []
h = 0
... |
s232371759 | p02262 | u298224238 | 1529471901 | Python | Python3 | py | Runtime Error | 0 | 0 | 662 | def insertionSort(arr, g):
cnt = 0
for i in range(g, len(arr)):
tmp = arr[i]
j = i - g
while(j >= 0 and arr[j] > tmp):
arr[j + g] = arr[j]
j -= g
cnt += 1
arr[j + 1] = tmp
return cnt
def shellSort(arr):
cnt = 0
g = []
h = 0
... |
s934196965 | p02262 | u298224238 | 1529471936 | Python | Python3 | py | Runtime Error | 0 | 0 | 664 | def insertionSort(arr, g):
cnt = 0
for i in range(g, len(arr)):
tmp = arr[i]
j = i - g
while(j >= 0 and arr[j] > tmp):
arr[j + g] = arr[j]
j -= g
cnt += 1
arr[j + 1] = tmp
return cnt
def shellSort(arr):
cnt = 0
g = []
h = 0
... |
s869940665 | p02262 | u298224238 | 1529472627 | Python | Python3 | py | Runtime Error | 0 | 0 | 663 | def insertionSort(arr, N, g):
cnt = 0
for i in range(g, N):
tmp = arr[i]
j = i - g
while(j >= 0 and arr[j] > tmp):
arr[j + g] = arr[j]
j -= g
cnt += 1
arr[j + g] = tmp
return cnt
def shellSort(arr, N):
cnt = 0
G = []
h = 0
... |
s676859517 | p02262 | u298224238 | 1529473395 | Python | Python3 | py | Runtime Error | 0 | 0 | 615 | cnt = 0
def insertionSort(arr, N, g):
for i in range(g, N):
tmp = arr[i]
j = i - g
while(j >= 0 and arr[j] > tmp):
arr[j + g] = arr[j]
j -= g
cnt += 1
arr[j + g] = tmp
def shellSort(arr, N):
G = []
h = 0
m = 0
while h <= N / 9:
... |
s273263706 | p02262 | u308033440 | 1529641655 | Python | Python3 | py | Runtime Error | 2540 | 13648 | 727 | def insertionSort(A,n,g):
for i in range(g,n,1):
v = int(A[i])
j = i - g
while j >= 0 and int(A[j]) > v:
global cnt
A[j + g] = A[j]
j = j - g
cnt = cnt + 1
A[j+g] = str(v)
def shellSort(A,n):
global cnt
global G
... |
s470441814 | p02262 | u308033440 | 1529641655 | Python | Python3 | py | Runtime Error | 2600 | 13648 | 727 | def insertionSort(A,n,g):
for i in range(g,n,1):
v = int(A[i])
j = i - g
while j >= 0 and int(A[j]) > v:
global cnt
A[j + g] = A[j]
j = j - g
cnt = cnt + 1
A[j+g] = str(v)
def shellSort(A,n):
global cnt
global G
... |
s071337637 | p02262 | u308033440 | 1529641697 | Python | Python3 | py | Runtime Error | 2590 | 13648 | 727 | def insertionSort(A,n,g):
for i in range(g,n,1):
v = int(A[i])
j = i - g
while j >= 0 and int(A[j]) > v:
global cnt
A[j + g] = A[j]
j = j - g
cnt = cnt + 1
A[j+g] = str(v)
def shellSort(A,n):
global cnt
global G
... |
s777127399 | p02262 | u285980122 | 1529642314 | Python | Python3 | py | Runtime Error | 20 | 5612 | 704 | def insertionSort(A, n, g):
global cnt
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt+=1
A[j+g] = v
def shellSort(A, n):
global cnt
cnt = 0
g = 2
m = n // g
print(m) # 1行目
... |
s564464872 | p02262 | u153665391 | 1529822074 | Python | Python3 | py | Runtime Error | 20 | 5604 | 784 | N = int(input())
A = [int(input()) for i in range(N)]
def insertion_sort(A, N, diff, cnt):
for i in range(diff, N):
tmp_num = A[i]
j = i - diff
while j >= 0 and A[j] > tmp_num:
A[j+diff] = A[j]
j = j - diff
cnt += 1
A[j+diff] = tmp_num
return ... |
s147559661 | p02262 | u316584871 | 1530182921 | Python | Python3 | py | Runtime Error | 8280 | 9836 | 919 | def insertionSort(A, n, g):
cnti = 0
for i in range(g, n):
v = A[i]
j = i-g
while (j >= 0 and A[j] > v):
A[j + g] = A[j]
j -= g
cnti += 1
A[j+g] = v
return cnti
def shellSort(A,n):
cnt = 0
G = []
for k in range(int((n/3)) +1):
... |
s298878277 | p02262 | u285980122 | 1530246902 | Python | Python3 | py | Runtime Error | 20 | 5608 | 1067 | def insertionSort(A, n, g):
global cnt
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt+=1
A[j+g] = v
def shellSort(A, n):
global cnt
cnt = 0
#g = 3
#g = n // 2 * 2
g = 2
... |
s221766270 | p02262 | u285980122 | 1530247004 | Python | Python3 | py | Runtime Error | 1720 | 9832 | 1077 | def insertionSort(A, n, g):
global cnt
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt+=1
A[j+g] = v
def shellSort(A, n):
global cnt
cnt = 0
#g = 3
#g = n // 2 * 2
g = 2
... |
s641962174 | p02262 | u285980122 | 1530247079 | Python | Python3 | py | Runtime Error | 1680 | 9832 | 1077 | def insertionSort(A, n, g):
global cnt
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt+=1
A[j+g] = v
def shellSort(A, n):
global cnt
cnt = 0
#g = 3
#g = n // 2 * 2
g = 2
... |
s273711766 | p02262 | u285980122 | 1530247450 | Python | Python3 | py | Runtime Error | 1920 | 9836 | 790 | def insertionSort(A, n, g):
global cnt
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt+=1
A[j+g] = v
def shellSort(A, n):
global cnt
cnt = 0
g = 4
G = [1]
m = 1
for i in ... |
s678255532 | p02262 | u285980122 | 1530247936 | Python | Python3 | py | Runtime Error | 3340 | 9832 | 815 | def insertionSort(A, n, g):
global cnt
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt+=1
A[j+g] = v
def shellSort(A, n):
global cnt
cnt = 0
g = 1
G = [1]
m = 1
for i in ... |
s619368441 | p02262 | u285980122 | 1530248115 | Python | Python3 | py | Runtime Error | 4030 | 9836 | 833 | def insertionSort(A, n, g):
global cnt
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt+=1
A[j+g] = v
def shellSort(A, n):
global cnt
cnt = 0
g = 1
G = [0]
m = 1
for i in ... |
s486198095 | p02262 | u285980122 | 1530248253 | Python | Python3 | py | Runtime Error | 4340 | 9840 | 832 | def insertionSort(A, n, g):
global cnt
for i in range(g,n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt+=1
A[j+g] = v
def shellSort(A, n):
global cnt
cnt = 0
g = 1
G = [1]
m = 1
for i in ... |
s095683071 | p02262 | u320121447 | 1530509461 | Python | Python3 | py | Runtime Error | 4840 | 9828 | 683 | def swap(A, i, j):
tmp = A[i]
A[i] = A[j]
A[j] = tmp
def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
def shellSort(A, n):
... |
s050083403 | p02262 | u320121447 | 1530509591 | Python | Python3 | py | Runtime Error | 1270 | 9836 | 703 | def swap(A, i, j):
tmp = A[i]
A[i] = A[j]
A[j] = tmp
def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
def shellSort(A, n):
... |
s093373899 | p02262 | u320121447 | 1530509815 | Python | Python3 | py | Runtime Error | 1330 | 9836 | 739 | def swap(A, i, j):
tmp = A[i]
A[i] = A[j]
A[j] = tmp
def insertionSort(A, n, g):
global cnt
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j = j - g
cnt += 1
A[j+g] = v
def shellSort(A, n):
... |
s074260882 | p02262 | u677291728 | 1530605968 | Python | Python3 | py | Runtime Error | 0 | 0 | 599 | #! /usr/bin/python
import sys
if sys.version_info[0] >= 3: raw_input = input
def insertion_sort(a,g):
global cnt
for i in range(g, len(a)):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j - g
cnt += 1
a[j+g] = v
def shell_sort(a):
global cnt
cnt = 0
g = ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.