Submission #1325315

#TimeUsernameProblemLanguageResultExecution timeMemory
1325315husseinjuanda세 명의 친구들 (BOI14_friends)C++20
0 / 100
86 ms12092 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int n; 

string c(string x){
    int f = n/2;
    string h = "";
    for(int i = 0; i < f; i++){
        h += x[i];
    }
    int co = 0;
    for(int i = 0; i < n; i++){
        if(co == f*2) break;
        if(h[co%f] == x[i]){
            co++;
        }
    }
    if(co == 2*f){
        return h;
    }else{
        return "LUCKYCHINA";
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    string x; cin >> x;
    string r_x = x;
    reverse(r_x.begin(), r_x.end());
    if(c(x) != "LUCKYCHINA" && c(r_x) != "LUCKYCHINA"){
        string h = c(r_x);
        reverse(h.begin(), h.end());
        if(h == c(x)){
            cout << h << "\n";
            return 0;
        }
        cout << "NOT UNIQUE" << "\n";
    }else if(c(x) == "LUCKYCHINA" && c(r_x) != "LUCKYCHINA"){
        string rx = c(r_x);
        reverse(rx.begin(), rx.end());
        cout << rx << "\n";
    }else if(c(x) != "LUCKYCHINA" && c(r_x) == "LUCKYCHINA"){
        cout << c(x) << "\n"; 
    }else{
        cout << "NOT POSSIBLE" << "\n";
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...