import sys
def process(line):
dupChrDict = {}
chrSet = set(line)
for c in chrSet:
if line.count(c) > 1:
dupChrDict[c] = list()
ind = 0
for c in line:
if c in dupChrDict:
dupChrDict[c].append(ind)
ind += 1
for c in line:
if c in dupChrDict:
printLine(c,dupChrDict[c])
del dupChrDict[c]
def printLine(c,indices):
info = list()
for index in indices:
info.append(c+':'+str(index))
print(*info,sep=',')
for line in sys.stdin:
line = line.strip()
process(line)
KY228 找位置
最新推荐文章于 2024-11-03 20:27:08 发布