#4499. [NERC2023] Kim's Quest
[NERC2023] Kim's Quest
[NERC2023] Kim's Quest
题目描述
In the long-forgotten halls of Kombinatoria's ancient academy, a gifted mathematician named Kim is faced with an unusual challenge. They found an old sequence of integers, which is believed to be a cryptic message from the legendary Kombinatoria's Oracle, and Kim wants to decipher its hidden meaning.Kim's mission is to find specific patterns within the sequence, known as Harmonious Subsequences. These are extraordinary subsequences where the sum of every three consecutive numbers is even, and each subsequence must be at least three numbers in length.
Given a sequence () of length , its subsequence of length is equal to and is uniquely defined by a set of indices , such that . Subsequences given by different sets of indices are considered different.
There's a twist in Kim's quest: the number of these Harmonious Subsequences could be overwhelming. To report the findings effectively, Kim must calculate the total number of these subsequences, presenting the answer as a remainder after dividing by the number .
输入格式
The first line contains a single integer $n$ --- the length of the sequence ($3 \le n \le 2 \cdot 10^5$).The second line contains space-separated integers --- the elements of the sequence ().
输出格式
Output one number --- the number of Harmonious Subsequences, modulo $998\,244\,353$.3
1 2 3
1
5
2 8 2 6 4
16
5
5 7 1 3 5
0
11
3 1 4 1 5 9 2 6 5 3 6
386
54
2 1 1 1 1 2 1 2 2 2 2 1 1 1 2 1 1 2
2 1 2 2 2 2 2 2 2 1 1 1 2 2 1 1 1 1
2 2 1 1 2 2 2 2 2 1 1 1 2 2 1 2 1 1
0