Submission #1078476

#TimeUsernameProblemLanguageResultExecution timeMemory
1078476oscar1fBroken Device (JOI17_broken_device)C++17
85 / 100
31 ms2900 KiB
#include<bits/stdc++.h>
#include "Annalib.h"
using namespace std;
using ll=long long;

static const ll TAILLE_MAX=150+5;
static bool estCache[TAILLE_MAX];
static ll nbVal;

static void envoi(vector<ll> v) {
    for (int i=0;i<nbVal;i++) {
        Set(i,v[i]);
    }
}

void Anna(int N,ll X,int K,int P[]) {
    nbVal=N;
    ll obj=X;
    ll nbCache=K;
    for (ll i=0;i<nbVal;i++) {
        estCache[i]=false;
    }
    for (ll i=0;i<nbCache;i++) {
        estCache[P[i]]=true;
    }
    vector<ll> listeTrois;
    while (obj>0) {
        listeTrois.push_back(obj%3);
        obj/=3;
    }
    vector<ll> ans;
    ll pos=0;
    while (pos<nbVal) {
        if (!listeTrois.empty() and !estCache[pos] and !estCache[pos+1]) {
            ans.push_back((listeTrois.back()+1)/2);
            ans.push_back((listeTrois.back()+1)%2);
            //cout<<1<<listeTrois.back();
            listeTrois.pop_back();
            pos+=2;
        }
        else {
            ans.push_back(0);
            ans.push_back(0);
            //cout<<0;
            pos+=2;
        }
    }
    envoi(ans);
    //cout<<endl;
}
#include<bits/stdc++.h>
#include "Brunolib.h"
using namespace std;
using ll=long long;

ll Bruno(int N,int A[]) {
    ll nbVal=N,rep=0,suiv;
    for (int i=0;i<nbVal;i+=2) {
        suiv=2*A[i]+A[i+1];
        if (suiv>0) {
            rep*=3;
            rep+=suiv-1;
        }
    }
    return rep;
}
#Verdict Execution timeMemoryGrader output
Fetching results...