#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
int n;
int a[100007];
long long dp[100007][207][3];//第i位值为j时k是否成立,k=0,i<i-1,k=1,i==i-1,k=2,i>i-1


int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=200;i++){
        if(a[1]!=-1&&a[1]!=i)
            dp[1][i][0]=0;
        else
            dp[1][i][0]=1;
        dp[1][i][1]=dp[1][i][2]=0;
    }
    long long sum=0;
    for(int i=2;i<=n;i++){
        sum=0;
        for(int x=1;x<=200;x++){
            if(a[i]!=-1&&a[i]!=x)
                dp[i][x][0]=0;
            else
                dp[i][x][0]=sum;
            sum+=(dp[i-1][x][0]+dp[i-1][x][1]+dp[i-1][x][2])%mod;
            sum%=mod;
        }
        for(int x=1;x<=200;x++){
            if(a[i]!=-1&&a[i]!=x)
                dp[i][x][1]=0;
            else
                dp[i][x][1]=(dp[i-1][x][0]+dp[i-1][x][1]+dp[i-1][x][2])%mod;
        }
        sum=0;
        for(int x=200;x>=1;x--){
            if(a[i]!=-1&&a[i]!=x)
                dp[i][x][2]=0;
            else
                dp[i][x][2]=sum;
            sum+=(dp[i-1][x][1]+dp[i-1][x][2])%mod;
            sum%=mod;
        }
    }
    long long ans=0;
    for(int i=1;i<=200;i++)
        ans+=(dp[n][i][1]+dp[n][i][2])%mod,ans%=mod;
    printf("%lld",ans);
    return 0;

}

Codeforces Round #518 (Div. 2) D(计数DP)的更多相关文章

  1. Codeforces Round #518 (Div. 2) [Thanks, Mail.Ru!]

    Codeforces Round #518 (Div. 2) [Thanks, Mail.Ru!] https://codeforces.com/contest/1068 A #include< ...

  2. Codeforces Round #131 (Div. 1) B. Numbers dp

    题目链接: http://codeforces.com/problemset/problem/213/B B. Numbers time limit per test 2 secondsmemory ...

  3. Codeforces Round #131 (Div. 2) B. Hometask dp

    题目链接: http://codeforces.com/problemset/problem/214/B Hometask time limit per test:2 secondsmemory li ...

  4. Codeforces Round #276 (Div. 1) D. Kindergarten dp

    D. Kindergarten Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/proble ...

  5. Codeforces Round #260 (Div. 1) A - Boredom DP

    A. Boredom Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/problem/A ...

  6. Codeforces Round #533 (Div. 2) C.思维dp D. 多源BFS

    题目链接:https://codeforces.com/contest/1105 C. Ayoub and Lost Array 题目大意:一个长度为n的数组,数组的元素都在[L,R]之间,并且数组全 ...

  7. Codeforces Round #539 (Div. 2) 异或 + dp

    https://codeforces.com/contest/1113/problem/C 题意 一个n个数字的数组a[],求有多少对l,r满足\(sum[l,mid]=sum[mid+1,r]\), ...

  8. Codeforces Round #374 (Div. 2) C. Journey DP

    C. Journey 题目连接: http://codeforces.com/contest/721/problem/C Description Recently Irina arrived to o ...

  9. Codeforces Round #202 (Div. 1) D. Turtles DP

    D. Turtles Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/547/problem/B ...

随机推荐

  1. CSS3 3D立体柜子实现

    1. [图片] 20140811233657.jpg 2. [图片] 120140811233846.jpg ​3. [代码][CSS]代码 body {      background-color: ...

  2. jQuery旋转插件jquery.rotate.js 让图片旋转

    演示1 直接旋转一个角度 $('#img1').rotate(45); 演示2 鼠标移动效果 $('#img2').rotate({ bind : { mouseover : function(){ ...

  3. 仿联想商城laravel实战---2、后端页面搭建(验证码如何在页面中使用)

    仿联想商城laravel实战---2.后端页面搭建(验证码如何在页面中使用) 一.总结 一句话总结: 放在img里面,img的src就是生产验证码的控制器路径: img src="/admi ...

  4. php mysqli_get_server_version()函数

    php mysqli_get_server_version()函数以整数形式返回MySQL服务器版本. 本文章想大家介绍mysqli_get_server_version 函数的基本使用方法和实例,需 ...

  5. Linux-iptables(2)

    iptables防火墙可以用于创建过滤(filter)与NAT规则.所有Linux发行版都能使用iptables,因此理解如何配置iptables将会帮助你更有效地管理Linux防火墙.如果你是第一次 ...

  6. CyclicBarrier与CountDownLatch的区别

    import java.util.concurrent.CountDownLatch; /** * 作用于单个线程或几个线程,,在其他线程执行完之前,一直等待(await)知道countDown为零 ...

  7. php实现多文件上传和下载。

    http://1229363.blog.163.com/blog/static/19743427200751291055264/

  8. 解决编译warning:warning: ‘MeteringUnit::voltage_gain_’ will be initialized after [-Wreorder]

    问题: 环境:ubuntu 12.04,g++版本4.6.3,编译目标文件时出现warnings: u1204@u1204-zhw:~/hwsvn/2sw/4prj_mips/UCP_rt5350/s ...

  9. 【LeetCode】019. Remove Nth Node From End of List

    Given a linked list, remove the nth node from the end of list and return its head. For example, Give ...

  10. Lua虚拟机初始化

    转自:http://www.cnblogs.com/ringofthec/archive/2010/11/09/lua_State.html 1. 创建lua虚拟机 lua_State *lua_ne ...