Submission #21552

# Submission time Handle Problem Language Result Execution time Memory
21552 2017-04-14T09:04:51 Z Ushio Broken Device (JOI17_broken_device) C++14
0 / 100
75 ms 4644 KB
#include "Annalib.h"
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;

const int FCT = 2;

int bitCount(int64_t x) {
    int ret = 0;
    while (x) {
        ++ret;
        x &= x - 1;
    }
    return ret;
}

void Anna( int N, long long X, int K, int P[] ){
    vector<int> per(N + FCT);
    srand(141417941L);
    for (int i = 0; i < N + FCT; ++i) {
        per[i] = i;
    }
    for (int i = 0; i < N; ++i) {
        int pos = i + rand() % (N - i);
        swap(per[i], per[pos]);
    }
    int bit = 0;
    int validity = 0;
    vector<bool> bad(N + FCT, false);
    for (int i = 0; i < FCT; ++i) {
        bad[per[N + i]] = true;
    }
    for (int i = 0; i < K; ++i) {
        bad[P[i]] = true;
    }
    int op = bitCount(X) > 30;
    bool modeSet = false;
    for (int i = 0; i < N; ++i) {
        if (validity == 0) {
            if (modeSet) {
                bool ok = bad[per[i]];
                for (int j = 1; j <= FCT; ++j) {
                    ok |= bad[per[i + j]] && bit + j - 1 <= 59 && 
                        (X & (1LL << (bit + j - 1))) != op;
                }
                if (ok) {
                    Set(per[i], 0);
                    validity = 0;
                } else {
                    Set(per[i], 1);
                    validity = FCT;
                }
            } else {
                if (bad[per[i]] || bad[per[i + 1]]) {
                    Set(per[i], 0);
                    validity = 0;
                } else {
                    Set(per[i], 1);
                    validity = 1;
                }
            }
        } else {
            if (modeSet) {
                if (bit <= 59) {
                    if (X & (1LL << bit)) {
                        Set(per[i], 1 ^ op);
                    } else {
                        Set(per[i], op);
                    }
                    bit++;
                } else {
                    Set(per[i], op);
                }
                validity--;
            } else {
                Set(per[i], op);
                modeSet = true;
                validity = 0;
            }
        }
    }
    cerr << "In: " << X << endl;
}
#include "Brunolib.h"
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;

const int FCT = 2;

long long Bruno( int N, int A[] ){
    vector<int> per(N + 1);
    srand(141417941L);
    for (int i = 0; i < N + 1; ++i) {
        per[i] = i;
    }
    for (int i = 0; i < N; ++i) {
        int pos = i + rand() % (N - i);
        swap(per[i], per[pos]);
    }
    int validity = 0;
    int bit = 0;
    int64_t ans = 0;
    bool modeSet = false;
    int op;
    for (int i = 0; i < N; ++i) {
        if (validity == 0) {
            if (modeSet) {
                validity = A[per[i]] * FCT;
            } else {
                validity = 1;
            }
        } else {
            if (modeSet) {
                if (bit <= 59) {
                    ans |= ((int64_t) A[per[i]] ^ op) << bit;
                    ++bit;
                }
                validity--;
            } else {
                op = A[per[i]];
                modeSet = true;
                validity = 0;
            }
        }
    }
    cerr << "Out: " << ans << endl;
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 4644 KB Output isn't correct - L* = 0
2 Partially correct 46 ms 4644 KB Output is partially correct - L* = 14
3 Incorrect 48 ms 4644 KB Output isn't correct - L* = 0
4 Incorrect 45 ms 4644 KB Output isn't correct - L* = 0
5 Incorrect 75 ms 4644 KB Output isn't correct - L* = 0
6 Partially correct 49 ms 4644 KB Output is partially correct - L* = 15
7 Partially correct 36 ms 4644 KB Output is partially correct - L* = 14
8 Incorrect 35 ms 4644 KB Output isn't correct - L* = 0
9 Incorrect 52 ms 4644 KB Output isn't correct - L* = 0
10 Incorrect 68 ms 4644 KB Output isn't correct - L* = 0
11 Incorrect 48 ms 4644 KB Output isn't correct - L* = 0
12 Incorrect 28 ms 4644 KB Output isn't correct - L* = 0
13 Incorrect 65 ms 4644 KB Output isn't correct - L* = 0
14 Incorrect 52 ms 4644 KB Output isn't correct - L* = 0
15 Incorrect 56 ms 4644 KB Output isn't correct - L* = 0
16 Incorrect 55 ms 4644 KB Output isn't correct - L* = 0
17 Incorrect 49 ms 4644 KB Output isn't correct - L* = 0
18 Incorrect 62 ms 4644 KB Output isn't correct - L* = 0
19 Partially correct 49 ms 4644 KB Output is partially correct - L* = 14
20 Incorrect 46 ms 4644 KB Output isn't correct - L* = 0
21 Incorrect 62 ms 4644 KB Output isn't correct - L* = 0
22 Partially correct 59 ms 4644 KB Output is partially correct - L* = 14
23 Incorrect 59 ms 4644 KB Output isn't correct - L* = 0
24 Partially correct 72 ms 4644 KB Output is partially correct - L* = 14
25 Incorrect 46 ms 4644 KB Output isn't correct - L* = 0
26 Incorrect 69 ms 4644 KB Output isn't correct - L* = 0
27 Partially correct 56 ms 4644 KB Output is partially correct - L* = 16
28 Incorrect 52 ms 4644 KB Output isn't correct - L* = 0
29 Incorrect 38 ms 4644 KB Output isn't correct - L* = 0
30 Incorrect 38 ms 4644 KB Output isn't correct - L* = 0
31 Incorrect 48 ms 4644 KB Output isn't correct - L* = 0
32 Incorrect 68 ms 4644 KB Output isn't correct - L* = 0
33 Partially correct 52 ms 4644 KB Output is partially correct - L* = 14
34 Partially correct 58 ms 4644 KB Output is partially correct - L* = 14
35 Incorrect 69 ms 4644 KB Output isn't correct - L* = 0
36 Partially correct 59 ms 4644 KB Output is partially correct - L* = 14
37 Incorrect 69 ms 4644 KB Output isn't correct - L* = 0
38 Incorrect 58 ms 4644 KB Output isn't correct - L* = 0
39 Incorrect 59 ms 4644 KB Output isn't correct - L* = 0
40 Partially correct 48 ms 4644 KB Output is partially correct - L* = 14