제출 #866985

#제출 시각아이디문제언어결과실행 시간메모리
866985haire세 명의 친구들 (BOI14_friends)Cpython 3
100 / 100
257 ms51968 KiB
n=int(input()) if n%2==0: print("NOT POSSIBLE") exit() n//=2 s=[*input()] def isValid(a,b): return a==b def bad(i): temp=s[:i]+s[i+1:] return isValid(temp[:n],temp[n:]) if isValid(s[1:n+1],s[n+1:]) and isValid(s[:n],s[n:-1]): if s[1:n+1] != s[:n]: print("NOT UNIQUE") exit() if isValid(s[1:n+1],s[n+1:]): print("".join(s[1:n+1])) exit() if isValid(s[:n],s[n:-1]): print("".join(s[n:-1])) exit() i=0 j=n+1 while i<n: if s[i]!=s[j]: wrong=i if bad(i): print("".join(s[n+1:])) exit() else: break i+=1 j+=1 i=0 j=n while i<n+1: if s[i]!=s[j]: wrong=j if bad(j): print("".join(s[:n])) exit() else: break i+=1 j+=1 print("NOT POSSIBLE")
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...