이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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\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... |