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 n,pos1,pos2,ct,ans;
string s,t,r,anss;
int main(){
ios::sync_with_stdio(false);
cin >> n >> s;
if (n%2 == 0){
cout << "NOT POSSIBLE\n";
return 0;
}
for (int i=1;i<=n/2;i++){
t+=s[i];
}
for (int i=n/2+1;i<n;i++){
r+=s[i];
}
for (int i=0;i<n/2;i++){
if (t[i] == r[i])
ct++;
}
for (int i=0;i<n;i++){
if (ct == n/2){
ans++;
anss=t;
}
if (pos1 != n/2){
if (t[pos1] == r[pos1])
ct--;
t[pos1]=s[i];
if (t[pos1] == r[pos1])
ct++;
pos1++;
}
else
{
if (t[pos2] == r[pos2])
ct--;
r[pos2]=s[i];
if (t[pos2] == r[pos2])
ct++;
pos2++;
}
}
if (ans > 1)
cout << "NOT UNIQUE\n";
else
if (ans == 0)
cout << "NOT POSSIBLE\n";
else
cout << anss << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |