제출 #382891

#제출 시각아이디문제언어결과실행 시간메모리
382891abil세 명의 친구들 (BOI14_friends)C++14
0 / 100
164 ms262148 KiB
#include <bits/stdc++.h>

#define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
#define int long long

using namespace std;

const int N = (1e6 + 12);
const int mod = (1e9 + 7);
const int inf = (1e9 + 7);

string p[N];

main(){
    SPEEDUP;
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(!(n & 1)){
        cout << "NOT POSSIBLE";
        return 0;
    }
    string a = "", b = "";
    for(int j = n / 2 + 1; j < n; j++){
        b.pb(s[j]);
    }
    for(int i = n / 2; i >= 0; i--){
        p[i] = a;
        a = s[i] + a;
    }
    a = "";
    vector<string > ans;
    for(int i = 0;i <= n / 2; i++){
        if(a + p[i] == b){
            ans.pb(b);
        }
        a.pb(s[i]);
    }
    b = "";
    a = "";
    for(int i = 0;i < n / 2; i++){
        a.pb(s[i]);
    }
    for(int i = n / 2; i < n; i++){
        p[i] = b;
        b.pb(s[i]);
    }
    b = "";
    for(int i = n / 2; i < n; i++){
        if(b + p[i] == a){
            ans.pb(a);
        }
        b.pb(s[i]);
    }
    if(ans.size() > 1){
        cout << "NOT UNIQUE";
        return 0;
    }
    if(ans.empty()){
        cout << "NOT POSSIBLE";
        return 0;
    }
    cout << ans[0];
}

컴파일 시 표준 에러 (stderr) 메시지

friends.cpp:19:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 | main(){
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...