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;
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define xx first
#define yy second
#define endl "\n"
int n;
string s;
int main()
{
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin>>n>>s;
n=s.size();
if (n%2==0) { cout<<"NOT POSSIBLE"; exit(0); }
bool istePolovine=true;
for (int i=0; i<n/2; i++)
if (s[i]!=s[n/2+i+1]) istePolovine=false;
if (istePolovine)
{
cout<<s.substr(0, n/2);
exit(0);
}
int koliko1=0; int koliko2=0;
int j=n/2;
for (int i=0; i<n/2; i++, j++)
while (j<n && s[i]!=s[j]) { koliko1++; j++; }
int k=0;
for (int i=n/2+1; i<n; i++, k++)
while (k<=n/2 && s[i]!=s[k]) { /*cout<<i<<" "<<k<<endl;*/ koliko2++; k++; }
if (koliko1>1 && koliko2>1) cout<<"NOT POSSIBLE";
else if (koliko1<=1 && koliko2<=1) cout<<"NOT UNIQUE";
else
{
if (koliko1<=1)
cout<<s.substr(0, n/2);
else
cout<<s.substr(n/2+1, n/2);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |