Submission #417792

#TimeUsernameProblemLanguageResultExecution timeMemory
417792DJeniUp세 명의 친구들 (BOI14_friends)C++17
100 / 100
83 ms9060 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll>pairll;
typedef pair<ll,pairll>pairlll;
typedef pair<pairll,pairll>pairllll;
typedef pair<ll,pairllll>pairlllll;
typedef long double ld;
typedef pair<ll,string>pairls;

#define endl '\n'
#define INF 1000000000007
#define M 1000000000
#define P 316
#define MOD 998244353
#define pb push_back
#define fr first
#define sc second

ll n,l,r,x,f;

string s,a,b;

int main()
{
    cin>>n>>s;
    if(n%2==0){
        cout<<"NOT POSSIBLE"<<endl;
        return 0;
    }
    for(int i=0;i<n/2;i++){
        a+=s[i];
    }
    for(int i=n/2+1;i<n;i++){
        b+=s[i];
    }
    x=0;
    f=0;
    for(int i=n/2;i<n;i++){
        if(a[x]!=s[i]){
            if(f==1){
                l=1;
            }else{
                f=1;
            }
        }else{
            x++;
        }
    }
    x=0;
    f=0;
    for(int i=0;i<=n/2;i++){
        if(b[x]!=s[i]){
            if(f==1){
                r=1;
            }else{
                f=1;
            }
        }else{
            x++;
        }
    }
    if(l==1 && r==1)cout<<"NOT POSSIBLE"<<endl;
    else if(l==0 && r==0 && a!=b)cout<<"NOT UNIQUE"<<endl;
    else if(l==0)cout<<a<<endl;
    else cout<<b<<endl;

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...