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>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
#include<iomanip>
#include<functional>
#include<stack>
#include<set>
#include<map>
#include<queue>
using namespace std;
int n;
int ballCnt;
bool isBase[3];
int res = 0;
int sol(int pos)
{
if (pos >= 3)
return 1;
if (!isBase[pos])
{
isBase[pos] = true;
return 0;
}
int ret = 0;
if (isBase[pos])
res += sol(pos + 1);
return ret;
}
int main()
{
#ifdef _CONSOLE
freopen("input.txt", "r", stdin);
#endif
//////////////////////////////////////////////////
scanf("%d", &n);
while (n--)
{
int point;
scanf("%d", &point);
if (point == 1)
{
ballCnt++;
if (ballCnt == 4)
{
res += sol(0);
ballCnt = 0;
}
}
else if (point == 2)
{
res += sol(0);
ballCnt = 0;
}
else
{
ballCnt++;
if (isBase[2])
{
res++;
isBase[2] = false;
}
for (int i = 1; i >= 0; i--)
{
if (isBase[i])
{
isBase[i + 1] = true;
isBase[i] = false;
}
}
if (ballCnt == 4)
{
isBase[0] = true;
ballCnt = 0;
}
}
printf("%d %d %d %d\n", isBase[2], isBase[1], isBase[0], res);
}
printf("%d\n", res);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |