Untitled
unknown
plain_text
2 years ago
610 B
3
Indexable
Never
# a = list(input()) # b = list(input()) from collections import defaultdict # a = list("CLOUD") # b = list("CUPID") # a = list("ALICE") # b = list("ELIBO") # a = "ABCBCYA" # b = list("ZBBACAA") #IPSSPIP d = defaultdict(int) passedB = defaultdict(list) for i in range(len(a)): if a[i] == b[i]: b[i] = 'P' else: if len(passedB[a[i]]) > 0: b[passedB[a[i]].pop(0)] = 'S' else: d[a[i]] += 1 if d[b[i]] > 0: d[b[i]] -= 1 b[i] = 'S' else: passedB[b[i]].append(i) b[i] = 'I' print(''.join(b))