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<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>
int p,x,s,i,j,b,a[4];
void f(int k)
{
if(k==4)s++;
else
{
if(a[k])f(k+1);
else a[k]=1;
}
}
main()
{
scanf("%d",&p);
for(i=0;i<p;i++)
{
scanf("%d",&x);
if(x==1)
{
b++;
if(b==4)f(1),b=0;
}
else if(x==2)
{
f(1),b=0;
}
else
{
for(j=3;j>=1;j--)
{
if(a[j])
{
if(j==3)s++;
else
{
a[j]=0;
a[j+1]=1;
}
}
}
if(b==4)f(1),b=0;
}
}
printf("%d",s);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |