F LIS = 3

#include <iostream>
#include <algorithm>
#include <cstdio>
 #include<bits/stdc++.h>
using namespace std;
 typedef long long ll;
const int MAXN = 1e6 + 10;
const int mod = 998244353;
int f[1001][12][12][12];
int c[5];
int n, m;
void solve() {
	cin >> n >> m;
	f[0][m + 1][m + 1][m + 1] = 1;
	for (int i = 1;  i<= n; i ++) {
		for (int j = 0;  j<= m + 1; j ++) {
			for (int k = j;  k<= m + 1; k ++) {
				for (int l = k; l <= m + 1; l ++) {
					if (!f[i - 1][j][k][l]) continue;//have ans 
					for (int x = 1; x <= m ; x ++) {
						for (int y = 1; y <= 4; y ++)
							c[y] = m + 1;
						c[1] = j, c[2] = k, c[3] = l;
						int tot = 0;
						for (int y = 1; y <= 3; y ++)					
							if (c[y] != m + 1) tot = y;
						if (x > c[tot]) {
							c[++tot] = x;
						}
						else {
							int p = 0;
							for (int y = 1;  y<= tot; y ++)
								if (x > c[y])  p = y;
							c[p + 1] = x;
						}
						if (tot <= 3)
						(f[i][c[1]][c[2]][c[3]] += f[i - 1][j][k][l] ) %= mod;
						//合法的时候tot=4表示不能为3 
					}
				}
			}
		}
	}
	int ans = 0;
		for (int j = 0;j <= m ; j ++) {
			for (int k = j + 1; k <= m ; k ++) {
				for (int l = k +1; l <= m ; l ++)
					ans = (ans + f[n][j][k][l]) % mod;
			}
		}
	
	cout << ans << endl;
}
int main () {
	int  t;
	t = 1;
	while (t --) solve();
	return 0;
} 

f[i][j][k][l]表示前i个数字,最长上升子序列长度为1的最右端的最小值为j,以此推,然后加入一个新的数,需要维护这个性质,考虑最长上升子序列的优化做法。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值