This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |