Submission #31371

# Submission time Handle Problem Language Result Execution time Memory
31371 2017-08-20T12:34:02 Z imaxblue Three Friends (BOI14_friends) C++14
0 / 100
16 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;
    fox(l, n/2+1){
        c[s[l]==s[l+n/2]]++;
    }
    fox(l, s.size()){
        if (l<=s.size()/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<s.size()/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 {
        s.erase(p, 1);
        cout << s;
    }
    return 0;
}

Compilation message

friends.cpp: In function 'int main()':
friends.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fox(k, x) for (int k=0; k<x; ++k)
                                  ^
friends.cpp:38:5: note: in expansion of macro 'fox'
     fox(l, s.size()){
     ^
friends.cpp:39:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (l<=s.size()/2)
              ^
friends.cpp:52:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (l<s.size()/2)
              ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 5280 KB Execution killed because of forbidden syscall writev (20)
2 Halted 0 ms 0 KB -