// source problem :
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
#define lb lower_bound
#define ub upper_bound
#define MASK(i) (1LL << (i))
const int inf = 1e18;
void ckmax(int& f, int s)
{
f = (f > s ? f : s);
}
void ckmin(int& f, int s)
{
f = (f < s ? f : s);
}
bool in(string s, string t)
{
int j = 0;
for (int i = 0; i < s.size() && j < t.size(); i++)
{
if (s[i] == t[j]) j++;
}
return j == t.size();
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
string s;
cin >> n >> s;
if (n % 2 == 0)
{
cout << "NOT POSSIBLE";
return 0;
}
int m = n / 2;
string a = s.substr(0, m), b = s.substr(m);
string c = s.substr(0, m + 1), d = s.substr(m + 1);
if (in(b, a))
{
if (in(c, d))
{
if (a != d) cout << "NOT UNIQUE";
else cout << a;
}
else cout << a;
}
else
{
if (in(c, d))
{
cout << d;
}
else cout << "NOT POSSIBLE";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |