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;
string s;
vector<string> ans;
void answer(string t)
{
cout << t << endl;
exit(0);
}
void test(string a, string b)
{
int pA = 0, pB = 0;
int qtdUnmatches = 0;
while( pA < (int)a.size() && pB < (int)b.size() )
{
if( a[pA] == b[pB] ) pA++, pB++;
else pB++, qtdUnmatches++;
}
if( qtdUnmatches > 1 ) return;
if( ans.empty() || ans.back() != a )
ans.push_back( a );
}
int main()
{
cin >> n >> s;
if( n%2 == 0 ) answer( "NOT POSSIBLE" );
n /= 2;
test( s.substr( 0 , n ) , s.substr( n , n + 1 ) );
test( s.substr( n + 1 , n ) , s.substr( 0 , n + 1 ) );
if( ans.empty() ) answer( "NOT POSSIBLE" );
if( ans.size() == 1 ) answer( ans.back() );
if( ans.size() == 2 ) answer( "NOT UNIQUE" );
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |