Created
May 17, 2022 08:57
-
-
Save mym0404/7cf58798973e8aa5777b805a7f193e39 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
n = int(input()) | |
k = int(input()) | |
arr = [int(input()) for _ in range(n)] | |
idx = [0 for _ in range(n)] | |
for i in range(n): | |
idx[i] = i | |
answer_set = set() | |
for on in itertools.permutations(idx): | |
idx_rev = [0 for _ in range(n)] | |
for i in on: | |
idx_rev[on[i]] = i | |
current = '' | |
for i in range(k): | |
current += str(arr[idx_rev[i]]) | |
answer_set.add(current) | |
print(len(answer_set)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment