This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main()
{
cin.tie(0);
ios::sync_with_stdio(0);
int sz;
cin >> sz;
string u;
cin >> u;
map<char, int>mp;
int not_twice = 0;
for (int i = 0; i < sz; i++)
{
mp[u[i]]++;
if (mp[u[i]] % 2 != 0)
{
not_twice++;
}
else
{
not_twice--;
}
}
if (not_twice > 1)
{
cout << "NOT POSSIBLE";
return 0;
}
int result = 0;
string kraj, l = "";
for (int i = 0; i < sz; i++)
{
if (mp[u[i]] % 2 != 0)
{
string r = u.substr(i + 1);
string temp = l + r;
if (temp.substr(0, sz / 2) == temp.substr(sz / 2))
{
result++;
if (result > 1)
{
cout << "NOT UNIQUE";
return 0;
}
kraj = temp.substr(0, sz / 2);
}
}
l += u[i];
}
cout << kraj;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |