Submission #44996096


Source Code Expand

#include<bits/stdc++.h>
#define LL long long
#define DB double
int MOD;
#define ls(x) x << 1
#define rs(x) x << 1 | 1
#define lowbit(x) x & (-x)
#define PII pair<int, int>
#define MP make_pair
#define VI vector<int>
#define VII vector<int>::iterator
#define all(x) x.begin(), x.end()
#define EB emplace_back
#define SI set<int>
#define SII set<int>::iterator
#define QI queue<int>
using namespace std;
template<typename T> void chkmn(T &a, const T &b) { (a > b) && (a = b); }
template<typename T> void chkmx(T &a, const T &b) { (a < b) && (a = b); }
int inc(const int &a, const int &b) { return a + b >= MOD ? a + b - MOD : a + b; }
int dec(const int &a, const int &b) { return a - b < 0 ? a - b + MOD : a - b; }
int mul(const int &a, const int &b) { return 1LL * a * b % MOD; }
int sqr(const int &a) { return 1LL * a * a % MOD; }
void Inc(int &a, const int &b) { ((a += b) >= MOD) && (a -= MOD); }
void Dec(int &a, const int &b) { ((a -= b) < 0) && (a += MOD); }
void Mul(int &a, const int &b) { a = 1LL * a * b % MOD; }
void Sqr(int &a) { a = 1LL * a * a % MOD; }
int qwqmi(int x, int k = MOD - 2)
{
	int res = 1;
	while(k)
	{
		if(k & 1) Mul(res, x);
		Sqr(x), k >>= 1;
	}
	return res;
}
const int N = 6e3 + 5;
int n;
int f[N][N << 1], ans;
int main()
{
	scanf("%d %d", &n, &MOD);
	n = n * 3;
	f[0][N] = 1;
	for(int i = 0; i < n; ++i)
		for(int j = N - i; j <= N + i; ++j)
		{
			Inc(f[i + 1][j + 1], f[i][j]);
			Inc(f[i + 2][j - 1], mul(f[i][j], i + 1));
			Inc(f[i + 3][j], mul(f[i][j], mul(i + 1, i + 2)));
		}
	for(int i = N; i < (N << 1); ++i)
		Inc(ans, f[n][i]);
	printf("%d\n", ans);
	return 0;
}

Submission Info

Submission Time
Task D - Merge Triplets
User Schucking_Sattin
Language C++ (GCC 9.2.1)
Score 1200
Code Size 1664 Byte
Status AC
Exec Time 712 ms
Memory 167456 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:43:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   43 |  scanf("%d %d", &n, &MOD);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1200 / 1200
Status
AC × 3
AC × 15
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt
Case Name Status Exec Time Memory
0_000.txt AC 6 ms 3564 KiB
0_001.txt AC 2 ms 3652 KiB
0_002.txt AC 30 ms 10980 KiB
1_003.txt AC 2 ms 3584 KiB
1_004.txt AC 7 ms 5196 KiB
1_005.txt AC 193 ms 50916 KiB
1_006.txt AC 6 ms 5112 KiB
1_007.txt AC 163 ms 43284 KiB
1_008.txt AC 50 ms 16948 KiB
1_009.txt AC 702 ms 165528 KiB
1_010.txt AC 711 ms 167204 KiB
1_011.txt AC 711 ms 167260 KiB
1_012.txt AC 712 ms 167452 KiB
1_013.txt AC 711 ms 167456 KiB
1_014.txt AC 710 ms 167124 KiB