CF1140E.Palindrome-less Arrays
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Let's denote that some array b is bad if it contains a subarray bl,bl+1,…,br of odd length more than 1 ( l<r and r−l+1 is odd) such that ∀i∈{0,1,…,r−l} bl+i=br−i .
If an array is not bad, it is good.
Now you are given an array a1,a2,…,an . Some elements are replaced by −1 . Calculate the number of good arrays you can obtain by replacing each −1 with some integer from 1 to k .
Since the answer can be large, print it modulo 998244353 .
输入格式
The first line contains two integers n and k ( 2≤n,k≤2⋅105 ) — the length of array a and the size of "alphabet", i. e., the upper bound on the numbers you may use to replace −1 .
The second line contains n integers a1,a2,…,an ( ai=−1 or 1≤ai≤k ) — the array a .
输出格式
Print one integer — the number of good arrays you can get, modulo 998244353 .
输入输出样例
输入#1
2 3 -1 -1
输出#1
9
输入#2
5 2 1 -1 -1 1 2
输出#2
0
输入#3
5 3 1 -1 -1 1 2
输出#3
2
输入#4
4 200000 -1 -1 12345 -1
输出#4
735945883