Run ID:67044
提交时间:2024-03-13 14:00:11
n,m = list(map(int,input().split())) a = list(map(int,input().split())) def selection_sort(tmp): a = tmp.copy() n = len(a) for i in range(n-1,0,-1): maxIdx = i for j in range(0,i): if a[j]>a[maxIdx]: maxIdx = j a[maxIdx],a[i] = a[i],a[maxIdx] return a tot = set() for i in range(n-m+1): b = a[i:i+m] res =a[:i] + selection_sort(b) + a[i+m:] tot.add(tuple(res)) print(len(tot))