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()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, cnt=0;
string s, a, b;
cin >> n >> s;
if (n%2==0)
{
cout << "NOT POSSIBLE";
return 0;
}
if (s.substr(0, n/2)==s.substr(n/2, n/2) && s.substr(1, n/2)==s.substr(n/2+1, n/2) && s.substr(0, n/2)!=s.substr(1, n/2))
{
cout << "NOT UNIQUE";
return 0;
}
a=s.substr(1, n/2);
b=s.substr(n/2+1, n/2);
for (int i=0; i<n/2; i++)
if (a[i]!=b[i])
cnt++;
if (!cnt)
{
cout << a;
return 0;
}
for (int i=0; i<n/2; i++)
{
if (a[i]!=b[i])
cnt--;
a[i]=s[i];
if (a[i]!=b[i])
cnt++;
if (!cnt)
{
cout << a;
return 0;
}
}
for (int i=0; i<n/2; i++)
{
if (a[i]!=b[i])
cnt--;
b[i]=s[n/2+i];
if (a[i]!=b[i])
cnt++;
if (!cnt)
{
cout << a;
return 0;
}
}
cout << "NOT POSSIBLE";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |