제출 #1168490

#제출 시각아이디문제언어결과실행 시간메모리
1168490aren_dance세 명의 친구들 (BOI14_friends)C++20
100 / 100
65 ms11188 KiB
#include <iostream>
#include <vector>
using namespace std;
const int N = 2e6+3;
const int p1=31;
const int p2 = 101;
int n;
vector<bool> vis1(26);
vector<bool> vis2(26);
string s;
const int mod = 1e9 + 7;
int main()
{
    cin >> n;
    cin >> s;
    if (n % 2 == 1) {
        string w = "";
        string e = "";
        for (int i = 0;i<n/2;++i) {
            w += s[i];
        }
        for (int i = n/2+1;i <n;++i) {
            e += s[i];
        }
        string r = w + w;
        string l = e+e;
        bool fl1 = 0;
        bool fl2 = 0;
        int vl1 = 0;
        int vl2 = 0;
        for (int i = 0;i < n;++i) {
            if (r[vl1]==s[i]) {
                vl1++;
            }
        }
        if (vl1 == n-1) {
            fl1 = 1;
        }
        for (int i = 0;i < n;++i) {
            if (l[vl2] == s[i]) {
                vl2++;
            }
        }
        if (vl2 == n - 1) {
            fl2 = 1;
        }
        if (fl1 == 0 && fl2 == 0) {
            cout << "NOT POSSIBLE";
        }
        else if (fl1 == 1 && fl2 == 1) {
            if (w == e) {
                cout << w;
            }
            else {
                cout << "NOT UNIQUE";
            }
        }
        else {
            if (fl1 == 1) {
                cout << w;
            }
            else {
                cout << e;
            }
        }
    }
    else {
        cout << "NOT POSSIBLE";
    }
    return 0;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...