Submission #29825351


Source Code Expand

// wargang

// 	Tell me why
// 	Ain't nothin' but a heartache
// 	Tell me why
// 	Ain't nothin' but a mistake
// 	Tell me why
// 	I never wanna hear you say
// 	I want it that way

#include <bits//stdc++.h>
using namespace std;

// MACROS
#define int                     long long
#define pb                      push_back
#define MAX                     2e18+5
#define MIN                     -2e18-5
#define mod                     998244353
#define eps                     1e-9
#define set(x)                  memset(x, 0, sizeof(x))
#define ff                      first
#define ss                      second
#define rep(i,a,b)              for(int i=a;i<b;i++)
#define sz(x)                   (int)x.size()
#define endl                    "\n"
#define deb(x)                  cout << #x << "=" << x << endl
#define deb2(x, y)              cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)           cout << #x << "=" << x << "," << #y << "=" << y<< "," << #z << "=" << z << endl
#define deb4(x, y, z, a)        cout << #x << "=" << x << "," << #y << "=" << y<< "," << #z << "=" << z << "," << #a << "=" << a << endl
#define all(x)                  x.begin(), x.end()

typedef pair<int, int>          pii;
typedef vector<int>             vi;
typedef vector<pii>             vpii;
typedef map<int, int>            mpii;
typedef set<int>                seti;
template<typename T, typename T1>T amax(T &a, T1 b) {if (b > a)a = b; return a;}
template<typename T, typename T1>T amin(T &a, T1 b) {if (b < a)a = b; return a;}

int mpow(int base, int exp);


// cout << fixed << setprecision(9) <<
const int N = 1000 + 5;
int n, m;
int dp[N][12][12][12];
// dp[i][j][k][l] = no. of sequences with lis array = {j, k, l}

void wargang() {
	cin >> n >> m;
	dp[0][m + 1][m + 1][m + 1] = 1;
	for (int i = 0; i < n; i++) {
		for (int fir = 1; fir <= m + 1; fir++) {
			for (int sec = fir; sec <= m + 1; sec++) {
				for (int third = sec; third <= m + 1; third++) {
					for (int x = 1; x <= m; x++) {
						if (x <= fir) {
							dp[i + 1][x][sec][third] += dp[i][fir][sec][third];
							dp[i + 1][x][sec][third] %= mod;
						} else if (x <= sec) {
							dp[i + 1][fir][x][third] += dp[i][fir][sec][third];
							dp[i + 1][fir][x][third] %= mod;
						} else if (x <= third) {
							dp[i + 1][fir][sec][x] += dp[i][fir][sec][third];
							dp[i + 1][fir][sec][x] %= mod;
						}
					}
					// deb4(i, fir, sec, third);
					// deb(dp[i][fir][sec][third]);
				}
			}
		}
	}
	int ans = 0;
	for (int fir = 1; fir <= m; fir++) {
		for (int sec = fir + 1; sec <= m; sec++) {
			for (int third = sec + 1; third <= m; third++) {
				// deb4(fir, sec, third, dp[n][fir][sec][third]);
				ans += dp[n][fir][sec][third];
				ans %= mod;
			}
		}
	}
	cout << ans << endl;


}



int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	for (int i = 1; i <= t; i++) {

		// cout<<"Case #"<<i<<": ";

		wargang();


	}
	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((int)result * base) % mod;
		base = ((int)base * base) % mod;
		exp >>= 1;
	}
	return result;
}

Submission Info

Submission Time
Task F - |LIS| = 3
User wargang
Language C++ (GCC 9.2.1)
Score 500
Code Size 3501 Byte
Status AC
Exec Time 28 ms
Memory 17128 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 28
Set Name Test Cases
Sample example0.txt, example1.txt, example2.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, example0.txt, example1.txt, example2.txt
Case Name Status Exec Time Memory
000.txt AC 6 ms 3544 KiB
001.txt AC 2 ms 3588 KiB
002.txt AC 13 ms 10048 KiB
003.txt AC 23 ms 17128 KiB
004.txt AC 24 ms 17068 KiB
005.txt AC 19 ms 14708 KiB
006.txt AC 12 ms 8600 KiB
007.txt AC 9 ms 6476 KiB
008.txt AC 14 ms 11828 KiB
009.txt AC 7 ms 6100 KiB
010.txt AC 5 ms 4504 KiB
011.txt AC 17 ms 13196 KiB
012.txt AC 9 ms 6924 KiB
013.txt AC 11 ms 6296 KiB
014.txt AC 15 ms 10768 KiB
015.txt AC 24 ms 16624 KiB
016.txt AC 27 ms 15776 KiB
017.txt AC 21 ms 16476 KiB
018.txt AC 13 ms 11344 KiB
019.txt AC 18 ms 15760 KiB
020.txt AC 22 ms 15804 KiB
021.txt AC 28 ms 16212 KiB
022.txt AC 21 ms 16716 KiB
023.txt AC 26 ms 16364 KiB
024.txt AC 11 ms 10012 KiB
example0.txt AC 2 ms 3604 KiB
example1.txt AC 2 ms 3584 KiB
example2.txt AC 4 ms 4336 KiB