From 31d8a152312a2a6c132ea1c75e007c42c83662fe Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 6 Feb 2023 22:14:33 +0800 Subject: [PATCH] =?UTF-8?q?1566.=20[NOI2009]=20=E7=AE=A1=E9=81=93=E5=8F=96?= =?UTF-8?q?=E7=8F=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://hydro.ac/d/bzoj/record/63e10b29dd8145683f7993dc --- BZOJ/1566/1566.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++ BZOJ/1566/data/1.in | 3 +++ BZOJ/1566/data/1.out | 3 +++ BZOJ/1566/data/10.in | 3 +++ BZOJ/1566/data/10.out | 3 +++ BZOJ/1566/data/2.in | 3 +++ BZOJ/1566/data/2.out | 3 +++ BZOJ/1566/data/3.in | 3 +++ BZOJ/1566/data/3.out | 3 +++ BZOJ/1566/data/4.in | 3 +++ BZOJ/1566/data/4.out | 3 +++ BZOJ/1566/data/5.in | 3 +++ BZOJ/1566/data/5.out | 3 +++ BZOJ/1566/data/6.in | 3 +++ BZOJ/1566/data/6.out | 3 +++ BZOJ/1566/data/7.in | 3 +++ BZOJ/1566/data/7.out | 3 +++ BZOJ/1566/data/8.in | 3 +++ BZOJ/1566/data/8.out | 3 +++ BZOJ/1566/data/9.in | 3 +++ BZOJ/1566/data/9.out | 3 +++ 21 files changed, 118 insertions(+) create mode 100644 BZOJ/1566/1566.cpp create mode 100644 BZOJ/1566/data/1.in create mode 100644 BZOJ/1566/data/1.out create mode 100644 BZOJ/1566/data/10.in create mode 100644 BZOJ/1566/data/10.out create mode 100644 BZOJ/1566/data/2.in create mode 100644 BZOJ/1566/data/2.out create mode 100644 BZOJ/1566/data/3.in create mode 100644 BZOJ/1566/data/3.out create mode 100644 BZOJ/1566/data/4.in create mode 100644 BZOJ/1566/data/4.out create mode 100644 BZOJ/1566/data/5.in create mode 100644 BZOJ/1566/data/5.out create mode 100644 BZOJ/1566/data/6.in create mode 100644 BZOJ/1566/data/6.out create mode 100644 BZOJ/1566/data/7.in create mode 100644 BZOJ/1566/data/7.out create mode 100644 BZOJ/1566/data/8.in create mode 100644 BZOJ/1566/data/8.out create mode 100644 BZOJ/1566/data/9.in create mode 100644 BZOJ/1566/data/9.out diff --git a/BZOJ/1566/1566.cpp b/BZOJ/1566/1566.cpp new file mode 100644 index 00000000..599f3e93 --- /dev/null +++ b/BZOJ/1566/1566.cpp @@ -0,0 +1,58 @@ +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 505; +const int mod = 1024523; + +int n, m, f[2][N][N]{1}; +std::string a, b; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n >> m >> a >> b; + + std::reverse(a.begin(), a.end()); + std::reverse(b.begin(), b.end()); + + a = ' ' + a; + b = ' ' + b; + + for (int k = 1; k <= n + m; k++) { + int t = k & 1, + p = t ^ 1; + + memset(f[t], 0x00, sizeof(f[t])); + + for (int i = std::max(0, k - m); i <= std::min(n, k); i++) { + for (int j = std::max(0, k - m); j <= std::min(n, k); j++) { + if (i && j && a[i] == a[j]) { + f[t][i][j] = (f[t][i][j] + f[p][i - 1][j - 1]) % mod; + } + + if (i && k - j && a[i] == b[k - j]) { + f[t][i][j] = (f[t][i][j] + f[p][i - 1][j]) % mod; + } + + if (k - i && j && b[k - i] == a[j]) { + f[t][i][j] = (f[t][i][j] + f[p][i][j - 1]) % mod; + } + + if (k - i && k - j && b[k - i] == b[k - j]) { + f[t][i][j] = (f[t][i][j] + f[p][i][j]) % mod; + } + } + } + } + + cout << f[(n + m) & 1][n][n] << endl; + + return 0; +} diff --git a/BZOJ/1566/data/1.in b/BZOJ/1566/data/1.in new file mode 100644 index 00000000..4a814828 --- /dev/null +++ b/BZOJ/1566/data/1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:71ea83145ee0bc5dd262b22b3890749bdc06811d8efdd35dc7320bf042c021bb +size 509 diff --git a/BZOJ/1566/data/1.out b/BZOJ/1566/data/1.out new file mode 100644 index 00000000..52d0e988 --- /dev/null +++ b/BZOJ/1566/data/1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1ee35c6ccedae99c86aabb0ca8e28cfb49582193bdafb52ffb31a629c1543f7d +size 5 diff --git a/BZOJ/1566/data/10.in b/BZOJ/1566/data/10.in new file mode 100644 index 00000000..95b66ee8 --- /dev/null +++ b/BZOJ/1566/data/10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:106cd8cb928fec44705cdc3ac497dbbe7003759b65226ca09fa438e517189ca7 +size 11 diff --git a/BZOJ/1566/data/10.out b/BZOJ/1566/data/10.out new file mode 100644 index 00000000..553db440 --- /dev/null +++ b/BZOJ/1566/data/10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9961d158a7e0e2f990765971a9e490af826c0743b7d603020f34cc8944319fcb +size 3 diff --git a/BZOJ/1566/data/2.in b/BZOJ/1566/data/2.in new file mode 100644 index 00000000..bdd99f70 --- /dev/null +++ b/BZOJ/1566/data/2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:80165ee2c754bc7acaf18f1f5e7c28220d851def519cd5b6089dfe38b39d0169 +size 810 diff --git a/BZOJ/1566/data/2.out b/BZOJ/1566/data/2.out new file mode 100644 index 00000000..8d170e52 --- /dev/null +++ b/BZOJ/1566/data/2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d72f4dc56a6acbbfeed2c454b073c7fbafe039b372d7784493226a9a46334c8a +size 7 diff --git a/BZOJ/1566/data/3.in b/BZOJ/1566/data/3.in new file mode 100644 index 00000000..2cdb5819 --- /dev/null +++ b/BZOJ/1566/data/3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:21d8c42f4fa4bb8b3c63160030e3c12b59907397a7852097920546b5c914bbee +size 108 diff --git a/BZOJ/1566/data/3.out b/BZOJ/1566/data/3.out new file mode 100644 index 00000000..2eb5005c --- /dev/null +++ b/BZOJ/1566/data/3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aae8aec2e2bf5efe8de87a3aa2772ff4f744161dc56741161ee4394c21bb7231 +size 7 diff --git a/BZOJ/1566/data/4.in b/BZOJ/1566/data/4.in new file mode 100644 index 00000000..383a268b --- /dev/null +++ b/BZOJ/1566/data/4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:96a9e7a4b4bfa4c1191148321f5ae7650a4279e2d29f56d3ed89d78c661c7e8a +size 32 diff --git a/BZOJ/1566/data/4.out b/BZOJ/1566/data/4.out new file mode 100644 index 00000000..402d96eb --- /dev/null +++ b/BZOJ/1566/data/4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6717f015895d9f351206c976a3a097be55d6630fd332020d9083e6e53e34a924 +size 7 diff --git a/BZOJ/1566/data/5.in b/BZOJ/1566/data/5.in new file mode 100644 index 00000000..d6439789 --- /dev/null +++ b/BZOJ/1566/data/5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:57ec1338013485e5e4e27556c59eca4acb0f3f724b84055ec4be89f9772cbd28 +size 310 diff --git a/BZOJ/1566/data/5.out b/BZOJ/1566/data/5.out new file mode 100644 index 00000000..0256a2f6 --- /dev/null +++ b/BZOJ/1566/data/5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:94b199dec5c4d0b78efb0bfd50876e128cdc9070827cbbfd5cfe2acee1f6a7bd +size 7 diff --git a/BZOJ/1566/data/6.in b/BZOJ/1566/data/6.in new file mode 100644 index 00000000..85f621ff --- /dev/null +++ b/BZOJ/1566/data/6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:403a9e9bd2cf0d92b058f1957850571530016a2eddc40fad465ec71a44f85af7 +size 22 diff --git a/BZOJ/1566/data/6.out b/BZOJ/1566/data/6.out new file mode 100644 index 00000000..92119e09 --- /dev/null +++ b/BZOJ/1566/data/6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:93da37d39013fe087726783a934c00184eb61594219d5fcf6ce2ed35fe206144 +size 6 diff --git a/BZOJ/1566/data/7.in b/BZOJ/1566/data/7.in new file mode 100644 index 00000000..d010d8c4 --- /dev/null +++ b/BZOJ/1566/data/7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e9fc7248fa5cf1a4c341f0eaf093c2555a0c59554b4028071f03b1f297ddf6e +size 690 diff --git a/BZOJ/1566/data/7.out b/BZOJ/1566/data/7.out new file mode 100644 index 00000000..56365344 --- /dev/null +++ b/BZOJ/1566/data/7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3657909aa9700917c86a233ca18e90290b2be79439b1f99b710b160af4429282 +size 7 diff --git a/BZOJ/1566/data/8.in b/BZOJ/1566/data/8.in new file mode 100644 index 00000000..62322047 --- /dev/null +++ b/BZOJ/1566/data/8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f793482f06fb9740c28c52beab0fe71bedea826e37d9e392cf75fae9491c3417 +size 1010 diff --git a/BZOJ/1566/data/8.out b/BZOJ/1566/data/8.out new file mode 100644 index 00000000..d731a825 --- /dev/null +++ b/BZOJ/1566/data/8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:14555a08c18890708032fcdfaf586453bb2c865fc02a979865284eef7b34fac0 +size 6 diff --git a/BZOJ/1566/data/9.in b/BZOJ/1566/data/9.in new file mode 100644 index 00000000..75a2c78b --- /dev/null +++ b/BZOJ/1566/data/9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42a7bb1eb325a14fda9a62f521eeaa262b89336d3de8b21713d03bbddccf113d +size 510 diff --git a/BZOJ/1566/data/9.out b/BZOJ/1566/data/9.out new file mode 100644 index 00000000..f2d44c11 --- /dev/null +++ b/BZOJ/1566/data/9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c344358c2c716c3283616aefc4da03d94f74bca6d70c54d85e642a59974228b8 +size 7