#P6739. [BalticOI 2014] Three Friends (Day1)

[BalticOI 2014] Three Friends (Day1)

Description

There is a string SS, and we perform the following operations on it:

  1. Copy SS into two copies and store them in the string TT.
  2. Insert one character at some position in TT to obtain the string UU.

Now, given UU, find SS.

Input Format

The first line contains an integer NN, representing the length of UU.
The second line contains NN characters, representing the string UU.

Output Format

  • If it is impossible to derive UU from SS using the steps above, output NOT POSSIBLE.
  • If the SS obtained from UU is not unique, output NOT UNIQUE.
  • Otherwise, output the string SS.
7
ABXCABC
ABC
6
ABCDEF
NOT POSSIBLE
9
ABABABABA
NOT UNIQUE

Hint

Constraints

This problem uses bundled testdata.

  • Subtask 1 (35 pts): N2001N \le 2001.
  • Subtask 2 (65 pts): no special constraints.

For 100%100\% of the testdata, 2N2×106+12 \le N \le 2 \times 10^6+1, and UU is guaranteed to contain only uppercase letters.

Notes

Translated from BalticOI 2014 Day1 B Three Friends

Translated by ChatGPT 5