Submission #58894

#TimeUsernameProblemLanguageResultExecution timeMemory
58894SpeedOfMagicThree Friends (BOI14_friends)C++17
0 / 100
1065 ms8880 KiB
/** MIT License Copyright (c) 2018 Vasilyev Daniil **/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
template<typename T> using v = vector<T>;
#define int long long
typedef string str;
typedef vector<int> vint;
#define rep(a, l, r) for(int a = (l); a < (r); a++)
#define pb push_back
#define sz(a) ((int) a.size())
const long long inf = 4611686018427387903; //2^62 - 1
#if 0  //FileIO
const string fileName = "";
ifstream fin ((fileName == "" ? "input.txt"  : fileName + ".in" ));
ofstream fout((fileName == "" ? "output.txt" : fileName + ".out"));
#define get fin>>
#define put fout<<
#else
#define get cin>>
#define put cout<<
#endif
#define eol put endl
void read() {}     template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get (arg)     ;read(args...) ;}
void print(){}     template<typename Arg,typename... Args> void print(Arg  arg,Args...  args){put (arg)<<" ";print(args...);}
void debug(){eol;} template<typename Arg,typename... Args> void debug(Arg  arg,Args...  args){put (arg)<<" ";debug(args...);}
int getInt(){int a; get a; return a;}
//code goes here
void run() {
    int n;
    get n;
    str u;
    get u;

    vint ans;
    int mid = n / 2;
    rep(i, 0, n) {
        str p1 = "", p2 = "";
        rep(j, 0, n)
            if (i != j) {
                if (sz(p1) == mid)
                    p2 += u[j];
                else
                    p1 += u[j];
            }
        if (p1 == p2)
            ans.pb(i);
    }
    //debug(ans[0]);
    if (sz(ans) == 0)
        put "NOT POSSIBLE";
    else if (sz(ans) == 1 || (sz(ans) == 2 && ans[0] == ans[1])) {
        rep(i, 0, n / 2)
            if (i != ans[0])
                put u[i];
            else
                n++;

    } else
        put "NOT UNIQUE";
}

int32_t main() {srand(time(0)); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); put fixed; put setprecision(15); run(); return 0;}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...