답안 #31377

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
31377 2017-08-20T12:45:23 Z imaxblue 세 명의 친구들 (BOI14_friends) C++14
0 / 100
13 ms 5280 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()

int n, c[2], p=-1;
string s;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.sync_with_stdio(0);
    cout.tie(0);
    cin >> n >> s;
    n=s.size();
    if (n%2==0){
        cout << "NOT POSSIBLE\n";
        return 0;
    }
    fox(l, n/2+1){
        c[s[l]==s[l+n/2]]++;
    }
    fox(l, n){
        if (l<=n/2)
            c[s[l]==s[l+n/2]]--;
        else
            c[s[l]==s[l-n/2-1]]--;
        if (c[0]==0){
            if (p!=-1){
                cout << "NOT UNIQUE\n";
                return 0;
            }
            p=l;
        }

        //cout << c[0] << endl;
        if (l<n/2)
            c[s[l]==s[l+n/2+1]]++;
        else
            c[s[l]==s[l-n/2]]++;
    }
    if (p==-1) cout << "NOT POSSIBLE\n";
    else {
        if (p>=n) while(1);
        s.erase(p, 1);
        cout << s << endl;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 5280 KB Execution killed because of forbidden syscall writev (20)
2 Halted 0 ms 0 KB -