func_code_string: #include <bits/stdc++.h>   using namespace std;   int a[2 * 100000 + 5];   int k, n;   long long dp[2][2 * 100000 + 5];   int mark[2 * 100000 + 5];   inline long long solve(int i, int lst) {     if (i == 0) {       if (lst == 1)         return 1ll;       else         return 0ll;     }     long long &ret = dp[lst][i];     if (ret != -1ll) return ret;     ret = 0ll;     if (lst == 0)       ret = (((k - 1) * 1ll) * solve(i - 1, 1)) % 998244353;     else {       long long tem = (k - 2) * 1ll;       tem = (tem * solve(i - 1, 1)) % 998244353;       tem = (tem + solve(i - 1, 0)) % 998244353;       ret = tem;     }     return ret;   }   inline int getNext(int i) {     for (int j = i + 2;; j += 2) {       if (a[j] != -1) return j;     }   }   inline long long pwr(int x, int p) {     if (p == 0) return 1ll;     if (p & 1) return ((1ll * x) * pwr(x, p - 1)) % 998244353;     long long ret = pwr(x, p / 2);     return (ret * ret) % 998244353;   }   int main() {     scanf( %d %d , &n, &k);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     a[n] = 10000000;     a[n + 1] = 10000000;     for (int i = 0; i < n; i++) {       if (a[i] == a[i + 2] && a[i] != -1) {         printf( 0 n );         return 0;       }     }     memset((dp), (-1), sizeof((dp)));     ;     long long ans = 1ll;     for (int i = 0; i < n; i++) {       if (a[i] == -1) {         if (i == 0 || i == 1) {           int nxt = getNext(i);           int pl = (nxt - i) / 2;           if (nxt >= n) {             ans = (ans * ((pwr(k - 1, pl - 1)) % 998244353)) % 998244353;             ans = (ans * (k * 1ll)) % 998244353;             continue;           }           ans = (ans * ((pwr(k - 1, pl)) % 998244353)) % 998244353;           continue;         }         if (a[i - 2] == -1) continue;         int nxt = getNext(i);         if (nxt >= n) {           int pl = (nxt - i) / 2;           ans = (ans * pwr(k - 1, pl)) % 998244353;         } else {           if (a[i - 2] == a[nxt]) {             int pl = (nxt - i) / 2;             ans = (ans * (k - 1ll)) % 998244353;             ans = (ans * solve(pl - 1, 1)) % 998244353;           } else {             int pl = (nxt - i) / 2;             long long tem;             tem = (k - 2ll) % 998244353;             tem = (tem * solve(pl - 1, 1)) % 998244353;             tem = (tem + (solve(pl - 1, 0))) % 998244353;             ans = (tem * ans) % 998244353;           }         }       }     }     printf( %lld n , ans);     ;     return 0;   }   