제출 #1357879

#제출 시각아이디문제언어결과실행 시간메모리
1357879tull세 명의 친구들 (BOI14_friends)C++20
0 / 100
1094 ms7992 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(A) A.begin(),A.end()
#define bp '\n'
#define vp cout<<'\n';
const int N=2e5+5;
int d[200];
signed main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    string a,b,c;
    int n=a.size(),cnt=0;
    cin>>n;
    cin>>a;
    for(auto&e:a)c+=e;
    string ans;
    unordered_set<string>st;
    for(int i=0;i<n;++i){
        reverse(all(c));
        c.pop_back();
        reverse(all(c));
        if(i>0)b+=a[i-1];
        string h=b;
        h+=c;
       //cout<<b<<":"<<c<<' '<<h<<'\n';
        int fl=1;
        for(int i=0;i<(n-1)/2;++i){
           // cout<<h[i]<<' '<<h[i+(n-1)/2]<<'\n';
            if(h[i]!=h[i+(n-1)/2]){
                fl=0;
                break;
            }
        }
        if(fl){
            ans=h;
            ++cnt;
            //st.emplace(h);
        }
    }
    if(cnt==0 or n%2==0){
        cout<<"NOT POSSIBLE";
    }else if(cnt>1){
        cout<<"NOT UNIQUE";
    }else{
        //cout<<ans;
        for(int i=0;i<(n-1)/2;++i){
            cout<<ans[i];
        }
    }
    cout<<'\n';
}
/*
3
print
the
poem

*/
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…