Submission #14097

#TimeUsernameProblemLanguageResultExecution timeMemory
14097comet볼질 (OJUZ10_ballparade)C++98
100 / 100
7 ms1276 KiB
#include<cstdio> int n,a[50010],b[4],ans; void push(int k){ if(k==3){ ans++; return; } if(b[k+1]==1){ push(k+1); } b[k+1]=b[k]; } void rotate(int k){ if(k){ push(0); } else{ if(b[3])ans++; for(int i=3;i>1;i--)b[i]=b[i-1]; b[1]=0; } } void f(){ int cnt=0; for(int i=0;i<n;i++){ b[0]=1; switch(a[i]){ case 1: cnt++; if(cnt==4){rotate(1);cnt=0;} break; case 2: cnt=0; rotate(1); break; default: rotate(0); cnt++; if(cnt==4){rotate(1);cnt=0;} break; } //for(int j=0;j<4;j++)printf("%d ",b[j]); //printf("cnt=%d ans=%d\n",cnt,ans); } } int main(){ scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&a[i]); } f(); printf("%d",ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...