# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
860761 | Ellinor | Three Friends (BOI14_friends) | C++14 | 0 ms | 0 KiB |
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())
n = N // 2
s = input()
if not N % 2:
print("NOT POSSIBLE")
exit(0)
ans = []
if s[1:n+1] == s[n+1:N]:
ans.append(s[1:n+1])
if s[0] == s[n]:
p = 0
ss = s[0]
for i in range(1,n):
if not s[i] == s[n + i + p]:
if p == 0:
p = 1
i -= 1
else:
p = 2
break
if p < 2:
if not s[0:n] in ans:
ans.append(s[0:n])
if s[0] == s[n + 1]:
p = 0
ss = s[n + 1]
for i in range(1,n):
if not s[i + p] == s[n + 1 + i]:
if p == 0:
p = 1
i -= 1
else:
p = 2
break
if p < 2:
if not s[n+1:N] in ans:
ans.append(s[n+1:N])
if len(ans) > 1:
print("NOT UNIQUE")
elif len(ans) == 1:
print(ans[0])
else:
print("NOT POSSIBLE")