제출 #398917

#제출 시각아이디문제언어결과실행 시간메모리
398917YaserFaisalThree Friends (BOI14_friends)C++14
0 / 100
6 ms4212 KiB
#include <bits/stdc++.h>
 
using namespace std ;
 
//#define int long long 
int MOD = 1e9+7 ;
int freq[200] ;
vector < int > v[200] ;

int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n ; cin >> n ; 
    string s ; cin >> s ; 
	if ( n % 2 == 0 )
    {
        cout << "NOT POSSIBLE" << endl ;
        return 0 ;
    }
    int counter = 0 , bo = 0 ;
    for ( int i = 0 , j = (n/2) ; i < (n/2) ; i++ , j++ )
    {
        if ( s[i] == s[j] ) counter++ ;
        else if ( !bo )
        {
            bo = 1 ;
            i-- ;
        }
        else { bo = 2 ; break ; }
    }
    string ans = "-" ;
    if ( bo == 1 ) ans = s.substr(0,(n/2)) ;
    //====================================================
    counter = bo = 0 ;
    for ( int i = (n/2)+1 , j = 0 ; i < n ; i++ , j++ )
    {
        if ( s[i] == s[j] ) counter++ ;
        else if ( !bo )
        {
            bo = 1 ;
            i-- ;
        }
        else { bo = 2 ; break ; }
    }
    if ( bo == 1 )
    {
        if ( ans == "-" || ans == s.substr((n/2)+1) ) ans = s.substr((n/2)+1) ;
        else
        {
            cout << "NOT UNIQUE" << endl ;
            return 0 ;
        }
    }
    if ( ans == "-" ) cout << "NOT POSSIBLE" << endl ;
    else cout << ans << endl ;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...