Skip to content

Instantly share code, notes, and snippets.

@mym0404
Created May 17, 2022 09:01
Show Gist options
  • Save mym0404/29c266ba6c30eea0e27c576174c63efa to your computer and use it in GitHub Desktop.
Save mym0404/29c266ba6c30eea0e27c576174c63efa to your computer and use it in GitHub Desktop.
n = int(input())
k = int(input())
arr = [int(input()) for _ in range(n)]
used = [False for _ in range(n)]
answer_set = set()
current_answer = []
def fn(K):
if K == 0:
tmp = ''
for number in current_answer:
tmp += str(number)
answer_set.add(tmp)
return
for i in range(n):
if used[i]: continue
used[i] = True
current_answer.append(arr[i])
fn(K - 1)
current_answer.pop()
used[i] = False
fn(k)
print(len(answer_set))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment