From b8ff26584962d730043ddc6556cbefa0f9da4288 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Fri, 10 Feb 2023 10:15:37 +0800 Subject: [PATCH] =?UTF-8?q?#1903.=20=E8=A2=AD=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://sjzezoj.com/submission/68864 --- S2OJ/1903/1903.cpp | 66 +++++++++++++++++++++++++++++++++++++ S2OJ/1903/data/attack1.in | 3 ++ S2OJ/1903/data/attack1.out | 3 ++ S2OJ/1903/data/attack10.in | 3 ++ S2OJ/1903/data/attack10.out | 3 ++ S2OJ/1903/data/attack2.in | 3 ++ S2OJ/1903/data/attack2.out | 3 ++ S2OJ/1903/data/attack3.in | 3 ++ S2OJ/1903/data/attack3.out | 3 ++ S2OJ/1903/data/attack4.in | 3 ++ S2OJ/1903/data/attack4.out | 3 ++ S2OJ/1903/data/attack5.in | 3 ++ S2OJ/1903/data/attack5.out | 3 ++ S2OJ/1903/data/attack6.in | 3 ++ S2OJ/1903/data/attack6.out | 3 ++ S2OJ/1903/data/attack7.in | 3 ++ S2OJ/1903/data/attack7.out | 3 ++ S2OJ/1903/data/attack8.in | 3 ++ S2OJ/1903/data/attack8.out | 3 ++ S2OJ/1903/data/attack9.in | 3 ++ S2OJ/1903/data/attack9.out | 3 ++ S2OJ/1903/data/problem.conf | 3 ++ 22 files changed, 129 insertions(+) create mode 100644 S2OJ/1903/1903.cpp create mode 100644 S2OJ/1903/data/attack1.in create mode 100644 S2OJ/1903/data/attack1.out create mode 100644 S2OJ/1903/data/attack10.in create mode 100644 S2OJ/1903/data/attack10.out create mode 100644 S2OJ/1903/data/attack2.in create mode 100644 S2OJ/1903/data/attack2.out create mode 100644 S2OJ/1903/data/attack3.in create mode 100644 S2OJ/1903/data/attack3.out create mode 100644 S2OJ/1903/data/attack4.in create mode 100644 S2OJ/1903/data/attack4.out create mode 100644 S2OJ/1903/data/attack5.in create mode 100644 S2OJ/1903/data/attack5.out create mode 100644 S2OJ/1903/data/attack6.in create mode 100644 S2OJ/1903/data/attack6.out create mode 100644 S2OJ/1903/data/attack7.in create mode 100644 S2OJ/1903/data/attack7.out create mode 100644 S2OJ/1903/data/attack8.in create mode 100644 S2OJ/1903/data/attack8.out create mode 100644 S2OJ/1903/data/attack9.in create mode 100644 S2OJ/1903/data/attack9.out create mode 100644 S2OJ/1903/data/problem.conf diff --git a/S2OJ/1903/1903.cpp b/S2OJ/1903/1903.cpp new file mode 100644 index 00000000..d6f25211 --- /dev/null +++ b/S2OJ/1903/1903.cpp @@ -0,0 +1,66 @@ +#include +#include + +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(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(fac[i - 1]) * i % mod; + } + + inv[0] = inv[1] = 1; + for (int i = 2; i < N; i++) { + inv[i] = static_cast(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(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(f[i][j]) + static_cast(f[i - 1][j - 1]) * (r[i] - j + 1) % mod + mod) % mod; + } + + f[i][j] = static_cast(f[i][j]) * A(i - j - l[i - 1], l[i] - l[i - 1]) % mod; + } + } + + cout << f[m][n] << endl; + + return 0; +} diff --git a/S2OJ/1903/data/attack1.in b/S2OJ/1903/data/attack1.in new file mode 100644 index 00000000..915c0250 --- /dev/null +++ b/S2OJ/1903/data/attack1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f6c747a1cbbb1d76338733297f8c100e843334a0e240cb5aef4f83b98e5e2b47 +size 39 diff --git a/S2OJ/1903/data/attack1.out b/S2OJ/1903/data/attack1.out new file mode 100644 index 00000000..051b2921 --- /dev/null +++ b/S2OJ/1903/data/attack1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:718b79e8f50ef54510673aae94fec2184c567c8261de965cccea64f659ffc1fb +size 7 diff --git a/S2OJ/1903/data/attack10.in b/S2OJ/1903/data/attack10.in new file mode 100644 index 00000000..d3acc2c2 --- /dev/null +++ b/S2OJ/1903/data/attack10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:031fe8b9c79fefc4fd6c2be7d16a22bc87ea9ee4607b76699a7ac7e41715f1e2 +size 13130 diff --git a/S2OJ/1903/data/attack10.out b/S2OJ/1903/data/attack10.out new file mode 100644 index 00000000..7ee4a427 --- /dev/null +++ b/S2OJ/1903/data/attack10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d5f21cac4da67d86a387e860d46ac34b19711a95efc241ef0c6df5666fc0b730 +size 10 diff --git a/S2OJ/1903/data/attack2.in b/S2OJ/1903/data/attack2.in new file mode 100644 index 00000000..dca6f984 --- /dev/null +++ b/S2OJ/1903/data/attack2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eeaf51634d34440abafa89437f8840285d3a56e445463168780d2c6e408fce15 +size 36 diff --git a/S2OJ/1903/data/attack2.out b/S2OJ/1903/data/attack2.out new file mode 100644 index 00000000..e81a3100 --- /dev/null +++ b/S2OJ/1903/data/attack2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc5ab3515b9b3096e3cf4f206b01a337ed13a2c344e6891f08e0dd6dc0950cc3 +size 8 diff --git a/S2OJ/1903/data/attack3.in b/S2OJ/1903/data/attack3.in new file mode 100644 index 00000000..c8e9ebcf --- /dev/null +++ b/S2OJ/1903/data/attack3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e92a71bd36280a2693c5daecfc6c85d4f46dbbdb0a5b706f0bd86dc8c3b3fd1d +size 88 diff --git a/S2OJ/1903/data/attack3.out b/S2OJ/1903/data/attack3.out new file mode 100644 index 00000000..689e57e4 --- /dev/null +++ b/S2OJ/1903/data/attack3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:221bd28494679491e1c27719cf35f0b1198720ee8b29381d1efb53ff01caa82a +size 10 diff --git a/S2OJ/1903/data/attack4.in b/S2OJ/1903/data/attack4.in new file mode 100644 index 00000000..25cf228b --- /dev/null +++ b/S2OJ/1903/data/attack4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:84535b3fb3bc5b7c4b5c9b0bc4c3acecc2435504d740f09701656054c78a1c72 +size 93 diff --git a/S2OJ/1903/data/attack4.out b/S2OJ/1903/data/attack4.out new file mode 100644 index 00000000..5b7a36db --- /dev/null +++ b/S2OJ/1903/data/attack4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dcce574566297c8ca3384dafd9cce2290e7c74c20b216a0ec5f89484fdffe0d7 +size 10 diff --git a/S2OJ/1903/data/attack5.in b/S2OJ/1903/data/attack5.in new file mode 100644 index 00000000..063ca4ad --- /dev/null +++ b/S2OJ/1903/data/attack5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aacd374d547361c97c1d3dad7775b0ab6cb40a8599e7577eb00cac9d2ad77eee +size 740 diff --git a/S2OJ/1903/data/attack5.out b/S2OJ/1903/data/attack5.out new file mode 100644 index 00000000..2aea828d --- /dev/null +++ b/S2OJ/1903/data/attack5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:df6a3f099e4954d7b4fd01378d36d462bedeb62ae48f91a76389ef2b78263cb6 +size 10 diff --git a/S2OJ/1903/data/attack6.in b/S2OJ/1903/data/attack6.in new file mode 100644 index 00000000..b8a99e6a --- /dev/null +++ b/S2OJ/1903/data/attack6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b713e144354ce52589badb938e9ed626f560ce9bc3784f7e2e6656220e19959 +size 890 diff --git a/S2OJ/1903/data/attack6.out b/S2OJ/1903/data/attack6.out new file mode 100644 index 00000000..1a9b9271 --- /dev/null +++ b/S2OJ/1903/data/attack6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f203407ceb7d57043b4f3f18b16b1f7e6891e5dff9ce94ddf7cd2562f60a449 +size 10 diff --git a/S2OJ/1903/data/attack7.in b/S2OJ/1903/data/attack7.in new file mode 100644 index 00000000..98091088 --- /dev/null +++ b/S2OJ/1903/data/attack7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e3eb0adf195b3d4fa32a4b3d8ddf42a730793ba3d490f41f753beb9650ec76d5 +size 925 diff --git a/S2OJ/1903/data/attack7.out b/S2OJ/1903/data/attack7.out new file mode 100644 index 00000000..97f31c02 --- /dev/null +++ b/S2OJ/1903/data/attack7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7267df5be9fc53272fe7dc40b21c82d4555dbab0c5bd8bc400d5701e97dc7248 +size 10 diff --git a/S2OJ/1903/data/attack8.in b/S2OJ/1903/data/attack8.in new file mode 100644 index 00000000..4aadfbfb --- /dev/null +++ b/S2OJ/1903/data/attack8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06854332dc3d8a124de5918a50ba6ed6d44df118ed30470dc33f92d81d9ffa16 +size 9352 diff --git a/S2OJ/1903/data/attack8.out b/S2OJ/1903/data/attack8.out new file mode 100644 index 00000000..4678a088 --- /dev/null +++ b/S2OJ/1903/data/attack8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0976ff8e16751b80ad4209c50e2ccc57d4e9734aee1f8075aaabb6599e509ea7 +size 10 diff --git a/S2OJ/1903/data/attack9.in b/S2OJ/1903/data/attack9.in new file mode 100644 index 00000000..f03a3b6e --- /dev/null +++ b/S2OJ/1903/data/attack9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e76831bdf2c187bee453df448f386e2add1a1d3184dd0429988cf65f5662a8e9 +size 11248 diff --git a/S2OJ/1903/data/attack9.out b/S2OJ/1903/data/attack9.out new file mode 100644 index 00000000..adc9c794 --- /dev/null +++ b/S2OJ/1903/data/attack9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9d791303971fbd0099244d4d8a5876f08170fc28db9dad1a600c84feb8c85a37 +size 10 diff --git a/S2OJ/1903/data/problem.conf b/S2OJ/1903/data/problem.conf new file mode 100644 index 00000000..d2c822c9 --- /dev/null +++ b/S2OJ/1903/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4c4ae0ec9240969607b1b65cc81a6cba1b47e5dd0e2fcfc3aab6063a1ced6af4 +size 212