Submission #584300

#TimeUsernameProblemLanguageResultExecution timeMemory
584300BlagojThree Friends (BOI14_friends)C++14
0 / 100
1075 ms11296 KiB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    int sz;
    cin >> sz;
    string u;
    cin >> u;
    map<char, int>mp;
    int not_twice = 0;
    for (int i = 0; i < sz; i++)
    {
        mp[u[i]]++;
        if (mp[u[i]] % 2 != 0)
        {
            not_twice++;
        }
        else
        {
            not_twice--;
        }
    }
    if (not_twice > 1)
    {
        cout << "NOT POSSIBLE";
        return 0;
    }
    int result = 0;
    string kraj, l = "";
    for (int i = 0; i < sz; i++)
    {
        if (mp[u[i]] % 2 != 0)
        {
            string r = u.substr(i + 1);
            string temp = l + r;
            if (temp.substr(0, sz / 2) == temp.substr(sz / 2))
            {
                result++;
                kraj = temp.substr(0, sz / 2);
            }
        }
        l += u[i];
        if (result > 1)
        {
            cout << "NOT UNIQUE";
            return 0;
        }
    }
    cout << kraj;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...