이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long int
const int mod = 1e9+7;
#undef int
int main()
{
#define int long long int
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(!(n&1))
    {
        cout<<"NOT POSSIBLE"<<endl;
        return 0;
    }
    int c = n/2, skip = 0;
    bool poss = true;string ans1 = "", ans2 = "";
    for(int i = 0;i<n/2;i++, c++)
    {
        if(s[i]!=s[c])
        {
            if(skip)
            {
                poss = false;
                break;
            }
            skip++;
            c++;
        }
    }
    if(poss)
        ans1 = s.substr(0, n/2);
    poss = true;
    c = 0, skip = 0;
    for(int i = n/2+1;i<n;i++, c++)
    { 
        if(s[i]!=s[c])
        {
            if(skip)
            {
                poss = false;
                break;
            }
            skip++;
            c++;
        }
    }
    if(poss)
        ans2 = s.substr(n/2+1);
    if(ans1!=""&&ans2!=""&&ans1!=ans2)
        cout<<"NOT UNIQUE"<<endl;
    else if(ans1!="")
        cout<<ans1<<endl;
    else if(ans2!="")
        cout<<ans2<<endl;
    else
        cout<<"NOT POSSIBLE"<<endl;
    return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |