# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
14951 | ztehgns | 볼질 (OJUZ10_ballparade) | C++98 | 0 ms | 0 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 <stdio.h>
void chkpush(bool*);
void push(bool*);
int ballcount;
int main(){
int n, ord. score=0
bool base[4];
base[0] = base[1] = base[2] = base[3] = false;
scanf("%d", &n);
for(int i=0;i<n;i++){
scanf("%d", &ord);
switch(ord){
case 1:
ballcount++;
break;
case 2:
ballcount = 0;
push(base);
break;
case 3:
ballcount++;
chkpush(base);
break;
}
if(ballcount==4)
ballcount = 0, push(base);
if(base[0]) base[0] = false, score++;
}
printf("%d\n", score);
return 0;
}
void chkpush(bool* base){
if(base[3])
base[0] = true, base[3] = false;
if(base[2])
base[3] = true, base[2] = false;
if(base[1])
base[2] = true, base[1] = false;
}
void push(bool* base){
if(base[3] && base[2] && base[1])
base[0] = true, base[3] = false;
if(base[2] && base[1])
base[3] = true, base[2] = false;
if(base[1])
base[2] = true, base[1] = false;
}