错误9%、实在是不知道为什么。
n = int(input()) s = list(input()) s1 = s[::-1] total = 0 """判断是否可以做回文串""" def check(S): count = 0 if len(S)%2 ==0: for s in S: if S.count(s) != 2: return False else: for s in S: if S.count(s) != 2: count += 1 if count >= 2: return False return True def swap(s,s1,n): global total if check("".join(s)): for i in range(n//2): a = s[i] if s.count(a) != 1: total += s1.index(a) s1.pop(s1.index(a)) s = s1[::-1] else: total += n//2 - i s1.pop(a) s = s1[::-1] swap(s,s1,n) if total != 0: print(total) else: print("Impossible")
0.0分
3 人评分
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:552 |
C语言考试练习题_排列 (C语言代码)浏览:1315 |
C语言程序设计教程(第三版)课后习题10.7 (C语言代码)浏览:958 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:659 |
WU-printf基础练习2 (C++代码)浏览:1999 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:500 |
The 3n + 1 problem (C语言代码)浏览:548 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:901 |
母牛的故事 (C语言代码)浏览:549 |
震宇大神的杀毒软件 (C语言代码)浏览:1079 |