Submission #21327

#TimeUsernameProblemLanguageResultExecution timeMemory
21327UshioBroken Device (JOI17_broken_device)C++14
41 / 100
65 ms4636 KiB
#include "Annalib.h"
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

void Anna( int N, long long X, int K, int P[] ){
    int bit = 0;
    bool validity = true;
    vector<bool> bad(N + 1, false);
    bad[N] = true;
    for (int i = 0; i < K; ++i) {
        bad[P[i]] = true;
    }
    for (int i = 0; i < N; ++i) {
        if (validity) {
            if (bad[i] || (bad[i + 1] && bit <= 59 && (X & (1LL << bit)))) {
                Set(i, 0);
                validity = true;
            } else {
                Set(i, 1);
                validity = false;
            }
        } else {
            if (bit <= 59) {
                if (X & (1LL << bit)) {
                    Set(i, 1);
                } else {
                    Set(i, 0);
                }
                bit++;
            } else {
                Set(i, 0);
            }
            validity = true;
        }
    }
    cerr << "In: " << X << endl;
}
#include "Brunolib.h"
#include <algorithm>
#include <iostream>
using namespace std;

long long Bruno( int N, int A[] ){
    bool validity = true;
    int bit = 0;
    int64_t ans = 0;
    for (int i = 0; i < N; ++i) {
        if (validity) {
            validity = A[i] == 0;
        } else {
            if (bit <= 59) {
                ans |= ((int64_t) A[i]) << bit;
                ++bit;
            }
            validity = true;
        }
    }
    cerr << "Out: " << ans << endl;
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...