Submission #102635

#TimeUsernameProblemLanguageResultExecution timeMemory
102635fanache99Broken Device (JOI17_broken_device)C++14
43 / 100
67 ms3312 KiB
#include "Annalib.h"

const int MAXN = 150;
const int BITS = 60;

int a[MAXN];
bool bad[MAXN];

void Anna(int n, long long x, int k, int p[]){
    for (int i = 0; i < n; i++) {
        bad[i] = false;
        a[i] = 0;
    }
    for (int i = 0; i < k; i++)
        bad[p[i]] = true;
    for (int i = BITS - 1, j = -1; i >= 0; i--) {
        if (x & (1LL << i))
            j += 2;
        else
            j++;
        while (j < n && bad[j])
            j += 2;
        if (j < n)
            a[j] = 1;
    }
    for (int i = 0; i < n; i++)
        Set(i, a[i]);
}

#include "Brunolib.h"

long long Bruno(int n, int a[]) {
    long long answer = 0;
    int bit = 0;
    for (int i = 0; i < n; i++) {
        if (!a[i])
            bit ^= 1;
        else {
            answer = answer * 2 + bit;
            bit = 0;
        }
    }
    return answer;
}

#Verdict Execution timeMemoryGrader output
Fetching results...