# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078607 | oscar1f | Broken Device (JOI17_broken_device) | C++17 | 17 ms | 3028 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "Annalib.h"
using namespace std;
using ll=long long;
static const ll TAILLE_MAX=150+5,NB_HASARD=(ll)(1000*1000*1000+9)*(ll)(1000*1000*1000+7);
static bool estCache[TAILLE_MAX];
static ll nbVal,numBloc,pos;
static vector<ll> ans,listeTrois;
static vector<vector<ll>> corres={{1,2,3},{3,1,2},{2,3,1}};
static void envoi(vector<ll> v) {
for (int i=0;i<nbVal;i++) {
Set(i,v[i]);
}
}
static void ajout() {
ans.push_back((corres[(NB_HASARD/numBloc)%3][listeTrois.back()])/2);
ans.push_back((corres[(NB_HASARD/numBloc)%3][listeTrois.back()])%2);
numBloc++;
listeTrois.pop_back();
pos+=2;
}
static void passe() {
ans.push_back(0);
ans.push_back(0);
numBloc+=2;
pos+=2;
}
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;
}
listeTrois.clear();
while (obj>0) {
listeTrois.push_back(obj%3);
obj/=3;
}
ans.clear();
pos=0;
numBloc=1;
int nbGagne=0;
while (pos<nbVal) {
if (!listeTrois.empty() and (!estCache[pos] or (corres[(NB_HASARD/numBloc)%3][listeTrois.back()])/2==0)
and (!estCache[pos+1] or (corres[(NB_HASARD/numBloc)%3][listeTrois.back()])%2==0)) {
if (estCache[pos] or estCache[pos+1]) {
nbGagne++;
}
ajout();
}
else {
passe();
}
}
cout<<nbGagne<<" ";
envoi(ans);
//cout<<endl;
}
#include<bits/stdc++.h>
#include "Brunolib.h"
using namespace std;
using ll=long long;
static const ll NB_HASARD=(ll)(1000*1000*1000+9)*(ll)(1000*1000*1000+7);
static vector<vector<ll>> corres{{0,1,2},{1,2,0},{2,0,1}};
ll Bruno(int N,int A[]) {
ll nbVal=N,rep=0,suiv,numBloc=1;
vector<ll> recu;
for (int i=0;i<nbVal;i+=2) {
suiv=2*A[i]+A[i+1]-1;
if (suiv>=0) {
rep*=3;
rep+=corres[(NB_HASARD/numBloc)%3][suiv];
numBloc++;
}
else {
numBloc+=2;
}
}
return rep;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |