0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-24 00:28:48 +00:00
https://sjzezoj.com/submission/68864
This commit is contained in:
Baoshuo Ren 2023-02-10 10:15:37 +08:00
parent c90f705060
commit b8ff265849
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
22 changed files with 129 additions and 0 deletions

66
S2OJ/1903/1903.cpp Normal file
View File

@ -0,0 +1,66 @@
#include <iostream>
#include <numeric>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 5005;
const int mod = 998244353;
int n, m, l[N], r[N], f[N][N];
int fac[N], inv[N], fac_inv[N];
int A(int n, int m) {
if (n < m || n < 0 || m < 0) return 0;
return static_cast<long long>(fac[n]) * fac_inv[n - m] % mod;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
fac[0] = 1;
for (int i = 1; i < N; i++) {
fac[i] = static_cast<long long>(fac[i - 1]) * i % mod;
}
inv[0] = inv[1] = 1;
for (int i = 2; i < N; i++) {
inv[i] = static_cast<long long>(mod - (mod / i)) * inv[mod % i] % mod;
}
fac_inv[0] = fac_inv[1] = 1;
for (int i = 2; i < N; i++) {
fac_inv[i] = static_cast<long long>(fac_inv[i - 1]) * inv[i] % mod;
}
cin >> n >> m;
for (int i = 1, x, y; i <= n; i++) {
cin >> x >> y;
l[x]++, r[y]++;
}
std::partial_sum(l + 1, l + 1 + m, l + 1);
std::partial_sum(r + 1, r + 1 + m, r + 1);
f[0][0] = 1;
for (int i = 1; i <= m; i++) {
for (int j = 0; j <= n; j++) {
f[i][j] = f[i - 1][j];
if (j - 1 >= 0 && r[i] - j + 1 >= 1) {
f[i][j] = (static_cast<long long>(f[i][j]) + static_cast<long long>(f[i - 1][j - 1]) * (r[i] - j + 1) % mod + mod) % mod;
}
f[i][j] = static_cast<long long>(f[i][j]) * A(i - j - l[i - 1], l[i] - l[i - 1]) % mod;
}
}
cout << f[m][n] << endl;
return 0;
}

BIN
S2OJ/1903/data/attack1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/attack9.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1903/data/problem.conf (Stored with Git LFS) Normal file

Binary file not shown.