Submission #860761

#TimeUsernameProblemLanguageResultExecution timeMemory
860761EllinorThree Friends (BOI14_friends)C++14
Compilation error
0 ms0 KiB
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")

Compilation message (stderr)

friends.cpp:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^