이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std ;
#define MAXN 2000007
int n ;
string a ;
int pref[ MAXN ] ;
int suff[ MAXN ] ;
bool f ( string s ) {
    int i ;
    int pos = 0 ;
    int br = 0 ;
    for ( i = 0 ; i < n ; i ++ ) {
        if ( a[ i ] == s[ pos ] ) {
            pos ++ ;
        }
        if ( pos == ( n / 2 ) ) {
            br ++ ;
            pos = 0 ;
        }
    }
    return ( br == 2 ) ;
}
void input ( ) {
    cin >> n ;
    cin >> a ;
}
void solve ( ) {
    if ( ( n % 2 ) == 0 ) { cout << "NOT POSSIBLE\n" ; return ; }
    int i ;
    int pos = ( n / 2 ) ;
    string x , y ;
    x.clear ( ) ;
    y.clear ( ) ;
    for ( i = 0 ; i < pos ; i ++ ) {
        x += a[ i ] ;
    }
    for ( i = pos + 1 ; i < n ; i ++ ) {
        y += a[ i ] ;
    }
    if ( x == y ) { cout << x << "\n" ; return ; }
    if ( f ( x ) == true && f ( y ) == true ) { cout << "NOT UNIQUE\n" ; }
    else if ( f ( x ) == true ) { cout << x << "\n" ; }
    else if ( f ( y ) == true ) { cout << y << "\n" ; }
    else { cout << "NOT POSSIBLE\n" ; }
}
int main ( ) {
    input ( ) ;
    solve ( ) ;
    return 0 ;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |