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 INF INT_MAX
#define output for(int i=0;i<sizex;i++) { for(int j=0;j<sizey;j++) { cout << moveChart[i][j] << " "; }cout<<endl; }cout<<endl;
const int maxN = 2001;
int N;
string s;
bool CHECK( string S ){
int n = S.length()/2;
return S.substr( 0, n ) == S.substr( n, n );
}
int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> N >> s;
if( !( N & 1 ) ){
cout << "NOT POSSIBLE" << endl; return 0;
}
string res;
int resCount = 0;
for(int i=0;i<N;i++){
string S = s.substr( 0, i ) + s.substr( i+1, INF );
if( CHECK( S ) ){
resCount++;
res = S;
}
if( resCount > 1 ) break;
}
if( !resCount ) cout << "NOT POSSIBLE" << endl;
else if( resCount == 1 ) cout << res.substr( 0, int(res.length())/2 ) << endl;
else cout << "NOT UNIQUE" << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |