• CF1051D Bicolorings dp


    水题一道

    $f[i][j][S]$表示$2 * i$的矩形,有$j$个联通块,某尾状态为$S$

    然后转移就行了...

    #include <vector>
    #include <cstdio>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    namespace remoon {
        #define re register
        #define de double
        #define le long double
        #define ri register int
        #define ll long long
        #define sh short
        #define pii pair<int, int>
        #define mp make_pair
        #define pb push_back
        #define tpr template <typename ra>
        #define rep(iu, st, ed) for(ri iu = st; iu <= ed; iu ++)
        #define drep(iu, ed, st) for(ri iu = ed; iu >= st; iu --)    
        extern inline char gc() {
            static char RR[23456], *S = RR + 23333, *T = RR + 23333;
            if(S == T) fread(RR, 1, 23333, stdin), S = RR;
            return *S ++;
        }
        inline int read() {
            int p = 0, w = 1; char c = gc();
            while(c > '9' || c < '0') { if(c == '-') w = -1; c = gc(); }
            while(c >= '0' && c <= '9') p = p * 10 + c - '0', c = gc();
            return p * w;
        }
        int wr[50], rw;
        #define pc(iw) putchar(iw)
        tpr inline void write(ra o, char c = '
    ') {
            if(!o) pc('0');
            if(o < 0) o = -o, pc('-');
            while(o) wr[++ rw] = o % 10, o /= 10;
            while(rw) pc(wr[rw --] + '0');
            pc(c);
        }
        tpr inline void cmin(ra &a, ra b) { if(a > b) a = b; }
        tpr inline void cmax(ra &a, ra b) { if(a < b) a = b; } 
        tpr inline bool ckmin(ra &a, ra b) { return (a > b) ? a = b, 1 : 0; }
        tpr inline bool ckmax(ra &a, ra b) { return (a < b) ? a = b, 1 : 0; }
    }
    using namespace std;
    using namespace remoon;
    
    #define mod 998244353
    
    inline void inc(ll &a, ll b) {
        a += b; if(a >= mod) a %= mod;
    }
    
    int n, k;
    ll f[1005][2010][4];
    
    int main() {
        n = read(); k = read();
        f[1][1][0] = 1; f[1][2][2] = 1;
        f[1][2][1] = 1; f[1][1][3] = 1;
        rep(i, 2, n)
        rep(j, 1, i << 1) {
            inc(f[i][j][0], f[i - 1][j][0] + f[i - 1][j][1] + f[i - 1][j][2] + f[i - 1][j - 1][3]);
            inc(f[i][j][1], f[i - 1][j - 1][0] + f[i - 1][j][1] + f[i - 1][j - 2][2] + f[i - 1][j - 1][3]);
            inc(f[i][j][2], f[i - 1][j - 1][0] + f[i - 1][j - 2][1] + f[i - 1][j][2] + f[i - 1][j - 1][3]);
            inc(f[i][j][3], f[i - 1][j - 1][0] + f[i - 1][j][1] + f[i - 1][j][2] + f[i - 1][j][3]);
        }
        ll ans = 0;
        inc(ans, f[n][k][0] + f[n][k][1] + f[n][k][2] + f[n][k][3]);
        write(ans);
        return 0;
    }
  • 相关阅读:
    Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean
    python 获取近几周日期
    vue node Failed at the iview-admin
    python 读取xls文件
    java正则解析ip
    JAVA操作Mongo 数组模糊查询
    Error connecting to the Service Control Manager: 拒绝访问 Mongodb问题-解决
    Voletile-多线程小例子
    新建VUE项目操作步骤(win7)
    mpvue开发小记
  • 原文地址:https://www.cnblogs.com/reverymoon/p/9773753.html
Copyright © 2020-2023  润新知