Submission #1297180

#TimeUsernameProblemLanguageResultExecution timeMemory
1297180nguyenkhangninh99Broken Device (JOI17_broken_device)C++20
85 / 100
19 ms1572 KiB
#include "Annalib.h"

#include<bits/stdc++.h>
using namespace std;

void Anna(int n, long long x, int k, int p[]){
    vector<int> res(n), bad(n);
    for(int i = 0; i < k; i++) bad[p[i]] = 1;
    vector<int> a;
    for(int i = 0; i < 38; i++){
        a.push_back(x % 3);
        x /= 3;
    }
    int cur = 0;
    for(int i = 0; i + 1 < n; i += 2){
        if(bad[i] || bad[i + 1]) continue;
        else{
            if(a[cur] == 0) res[i] = 1;
            if(a[cur] == 1) res[i + 1]  = 1;
            if(a[cur] == 2) res[i] = res[i + 1] = 1;
            cur++;
            if(cur == 38) break;
        }
    }
    for(int i = 0; i < n; i++) Set(i, res[i]);
}
#include "Brunolib.h"
#include<bits/stdc++.h>
using namespace std;

long long Bruno(int n, int a[]){
    long long ans = 0, bit = 1;
    for(int i = 0; i + 1 < n; i += 2){
        if(a[i] == 0 && a[i + 1] == 0) continue;
        if(a[i] == 0 && a[i + 1] == 1) ans += bit * 1;
        if(a[i] == 1 && a[i + 1] == 1) ans += bit * 2;
        bit *= 3;
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...