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>
#define fi first
#define se second
#define ll long long
const int INF=1e9+1;
const int MAXN=1e5+1;
const int MOD=13371337;
using namespace std;
int 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;
}
bool cnt=0;
string ans;
for (int i=0; i<n; i++) {
string st=s;
string st1,st2;
if (i<=n/2) {
for (int j=0; j<(n-1)/2+1; j++)
if (i!=j)
st1+=st[j];
for (int j=(n-1)/2+1; j<n; j++)
st2+=st[j];
}
else {
for (int j=0; j<(n-1)/2; j++)
st1+=st[j];
for (int j=(n-1)/2; j<n; j++)
if (i!=j)
st2+=st[j];
}
//cout << st1 << " " << st2 << "\n";
if (st1==st2) {
if (cnt) {
if (ans!=st1) {
cout << "NOT UNIQUE";
return 0;
}
}
else {
cnt++;
ans=st1;
}
}
}
if (cnt==0)
cout << "NOT POSSIBLE";
else
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |