Submission #61206

#TimeUsernameProblemLanguageResultExecution timeMemory
61206baboBroken Device (JOI17_broken_device)C++14
0 / 100
82 ms3888 KiB
//#include "Annalib.h" #include <bits/stdc++.h> #define L long long using namespace std; void Set(int,int); int a[150]; void Anna(int N,L X,int K,int P[]){ int i; L bit=1; for(i=0;i<K;i++) { a[P[i]]=-1; } for(i=0;i<N;i+=3) { //printf("%lld\n",i); if(X<bit) break; L sum=a[i]+a[i+1]+a[i+2]; if(sum<=-2) continue; if(sum==0) { switch(X/bit%4){ case 0: a[i]=a[i+1]=a[i+2]=1; break; case 1: a[i+2]=1; break; case 2: a[i]=a[i+1]=1; break; case 3: a[i+1]=a[i+2]=1; } bit<<=2; } else { if(a[i]==-1) { if(X/bit%2==0) { a[i+1]=1; bit<<=1; } else { if(X/bit%4==1) { a[i+2]=1; } else { a[i+1]=a[i+2]=1; } bit<<=2; } } else if(a[i+1]==-1) { if(X/bit%2) { a[i]=1; } else { a[i]=a[i+2]=1; } bit<<=1; } else { if(X/bit%2) { a[i]=1; } else { a[i+1]=1; } bit<<=1; } } if(X<bit) break; } for(i=0;i<N;i++) { if(a[i]==1) Set(i,1); else Set(i,0); } } /* int p[100010]; int aa[100010]; void Set(int loc,int val){ aa[loc]=val; } L con[8]={ 0,1,0,3,1,0,2,0 }; L shi[8]{ 0,2,1,2,1,1,2,2 }; L Bruno(int N,int A[]){ L ret=0,i,bit=1; for(i=0;i<N;i+=3) { L temp=A[i]*4+A[i+1]*2+A[i+2]; ret+=bit*con[temp]; //printf("%lld %lld\n",bit,temp); bit<<=shi[temp]; } return ret; } int main() { L n,k,x; scanf("%lld %lld %lld",&n,&k,&x); for(int i=0;i<k;i++) { scanf("%lld",&p[i]); } Anna(n,x,k,p); for(int i=0;i<n;i++) { printf("%d ",aa[i]); } puts(""); printf("%lld ",Bruno(n,aa)); } //*/
#include "Brunolib.h" #include <bits/stdc++.h> #define L long long using namespace std; L con[8]={ 0,1,0,3,1,0,2,0 }; L shi[8]{ 0,2,1,2,1,1,2,2 }; L Bruno(int N,int A[]){ L ret=0,i,bit=1; for(i=0;i<N;i+=3) { L temp=A[i]*4+A[i+1]*2+A[i+2]; ret+=bit*con[temp]; //printf("%lld %lld\n",bit,temp); bit<<=shi[temp]; } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...