Skip to content

Instantly share code, notes, and snippets.

@monhime
Created August 21, 2021 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monhime/1911b97dc4e1e32452044a45ecd1cc52 to your computer and use it in GitHub Desktop.
Save monhime/1911b97dc4e1e32452044a45ecd1cc52 to your computer and use it in GitHub Desktop.
ABC215_C
import sys, math, copy
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from typing import Container
# sys.setrecursionlimit(1000000)
def input(): return sys.stdin.readline().rstrip()
def main():
mod = 10**9 + 7
inf = 10**10
s, k = input().split()
k = int(k)
S_lis = list(permutations(list(s)))
S_lis_2 = ["".join(s) for s in S_lis]
S_lis_2_c = Counter(S_lis_2)
print(sorted(S_lis_2_c.keys())[k - 1])
if __name__=='__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment