Submission #1078421

#TimeUsernameProblemLanguageResultExecution timeMemory
1078421oscar1fBroken Device (JOI17_broken_device)C++17
43 / 100
27 ms2732 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 pair<bool,vector<ll>> calc(vector<ll> listeBit) { vector<ll> ans; ll pos=0; while (pos<nbVal) { if (!listeBit.empty() and !estCache[pos] and pos<nbVal-1 and (!estCache[pos+1] or listeBit.back()==0)) { ans.push_back(1); ans.push_back(listeBit.back()); //cout<<1<<listeBit.back(); listeBit.pop_back(); pos+=2; } else { ans.push_back(0); //cout<<0; pos++; } } if (listeBit.empty()) { return {true,ans}; } else { return {false,ans}; } } 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> listeBit; while (obj>0) { listeBit.push_back(obj%2); obj/=2; } /*for (ll i:listeBit) { cout<<i; } cout<<endl;*/ auto bonSens=calc(listeBit); if (bonSens.first) { envoi(bonSens.second); } else { for (ll i=0;i<(ll)listeBit.size();i++) { listeBit[i]=1-listeBit[i]; } envoi(calc(listeBit).second); } //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,pos=0,rep=0; vector<ll> recu; while (pos<nbVal) { if (A[pos]==1) { recu.push_back(A[pos+1]); pos+=2; } else { pos++; } } if (recu.empty()) { return rep; } if (recu[0]==0) { for (ll i:recu) { rep*=2; rep+=1-i; } } else { for (ll i:recu) { rep*=2; rep+=i; } } //cout<<"!"<<rep<<endl; return rep; }
#Verdict Execution timeMemoryGrader output
Fetching results...