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 <iostream>
#include <map>
#include <vector>
#include <climits>
#include <stack>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <iostream>
#include <unordered_map>
#include <cmath>
#include <cctype>
#include <bitset>
#include <iomanip>
#include <cstring>
using namespace std;
#define int long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int32_t main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
string s, a="", b="";
cin>>n>>s;
for (int i=0; i<n/2; ++i)a+=s[i];
for (int i=n-1; i>n-n/2-1; --i)b=s[i]+b;
bool one=1, can=1, can2=1;
int p=0;
for (int i=0; i<1+(n-1)/2; ++i){
if (b[p]==s[i])++p;
else if (one)one=0;
else {can=0;break;}
}
one=1;
p=0;
for (int i=n/2; i<n; ++i){
if (a[p]==s[i])++p;
else if (one)one=0;
else {can2=0;break;}
}
if (!(n%2))cout<<"NOT POSSIBLE";
else if (can&&can2&&n>=9)cout<<"NOT UNIQUE";
else if (can)cout<<b;
else if (can2)cout<<a;
else cout<<"NOT POSSIBLE";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |