You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
919 B
C++

#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int a[105], n;
int main()
{
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", a + i);
for (int i = 1; i < n; i++)
if ((a[i] == 3 && a[i - 1] == 2) || (a[i] == 2 && a[i - 1] == 3))
{
puts("Infinite");
return 0;
}
puts("Finite");
int ans = 0;
for (int i = 1; i < n; i++)
{
if (a[i - 1] == 1 && a[i] == 2)
ans += 3;
if (a[i - 1] == 2 && a[i] == 1)
ans += 3;
if (a[i - 1] == 1 && a[i] == 3)
ans += 4;
if (a[i - 1] == 3 && a[i] == 1)
ans += 4;
}
for (int i = 2; i < n; i++)
if (a[i - 2] == 3 && a[i - 1] == 1 && a[i] == 2)
ans--;
printf("%d", ans);
return 0;
}