From 7a99b6b16e3147234e603a5e8ade1580ce95c5ea Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 2 Nov 2022 21:34:17 +0800 Subject: [PATCH] =?UTF-8?q?#1731.=20=E3=80=902022.11.02=20=E8=81=94?= =?UTF-8?q?=E8=80=83=E3=80=91=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=94=9F=E6=88=90?= =?UTF-8?q?=EF=BC=88monkey=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://sjzezoj.com/submission/63219 --- S2OJ/1731/1731.cpp | 55 +++++++++++++++++++++++++++++++++++++ S2OJ/1731/data/monkey1.in | 3 ++ S2OJ/1731/data/monkey1.out | 3 ++ S2OJ/1731/data/monkey10.in | 3 ++ S2OJ/1731/data/monkey10.out | 3 ++ S2OJ/1731/data/monkey2.in | 3 ++ S2OJ/1731/data/monkey2.out | 3 ++ S2OJ/1731/data/monkey3.in | 3 ++ S2OJ/1731/data/monkey3.out | 3 ++ S2OJ/1731/data/monkey4.in | 3 ++ S2OJ/1731/data/monkey4.out | 3 ++ S2OJ/1731/data/monkey5.in | 3 ++ S2OJ/1731/data/monkey5.out | 3 ++ S2OJ/1731/data/monkey6.in | 3 ++ S2OJ/1731/data/monkey6.out | 3 ++ S2OJ/1731/data/monkey7.in | 3 ++ S2OJ/1731/data/monkey7.out | 3 ++ S2OJ/1731/data/monkey8.in | 3 ++ S2OJ/1731/data/monkey8.out | 3 ++ S2OJ/1731/data/monkey9.in | 3 ++ S2OJ/1731/data/monkey9.out | 3 ++ S2OJ/1731/data/problem.conf | 3 ++ 22 files changed, 118 insertions(+) create mode 100644 S2OJ/1731/1731.cpp create mode 100644 S2OJ/1731/data/monkey1.in create mode 100644 S2OJ/1731/data/monkey1.out create mode 100644 S2OJ/1731/data/monkey10.in create mode 100644 S2OJ/1731/data/monkey10.out create mode 100644 S2OJ/1731/data/monkey2.in create mode 100644 S2OJ/1731/data/monkey2.out create mode 100644 S2OJ/1731/data/monkey3.in create mode 100644 S2OJ/1731/data/monkey3.out create mode 100644 S2OJ/1731/data/monkey4.in create mode 100644 S2OJ/1731/data/monkey4.out create mode 100644 S2OJ/1731/data/monkey5.in create mode 100644 S2OJ/1731/data/monkey5.out create mode 100644 S2OJ/1731/data/monkey6.in create mode 100644 S2OJ/1731/data/monkey6.out create mode 100644 S2OJ/1731/data/monkey7.in create mode 100644 S2OJ/1731/data/monkey7.out create mode 100644 S2OJ/1731/data/monkey8.in create mode 100644 S2OJ/1731/data/monkey8.out create mode 100644 S2OJ/1731/data/monkey9.in create mode 100644 S2OJ/1731/data/monkey9.out create mode 100644 S2OJ/1731/data/problem.conf diff --git a/S2OJ/1731/1731.cpp b/S2OJ/1731/1731.cpp new file mode 100644 index 00000000..82c34e8d --- /dev/null +++ b/S2OJ/1731/1731.cpp @@ -0,0 +1,55 @@ +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 1e6 + 5; +const int mod = 1e9 + 7; + +int nxt[N], f[N][2], p[N], a[N], b[N]; +std::string s; + +int binpow(int a, int b) { + int res = 1; + + while (b) { + if (b & 1) res = static_cast(res) * a % mod; + a = static_cast(a) * a % mod; + b >>= 1; + } + + return res; +} + +signed main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> s; + + s = ' ' + s; + + for (int i = 2, j = 0; i < s.size(); i++) { + while (j && s[i] != s[j + 1]) j = nxt[j]; + if (s[i] == s[j + 1]) j++; + nxt[i] = j; + } + + for (int i = 1; i < s.size(); i++) { + bool x = s[i] - '0'; + f[i - 1][x] = i; + p[i - 1] = f[i - 1][x ^ 1] = f[nxt[i - 1]][x ^ 1]; + } + + a[0] = 1; + + for (int i = 1; i < s.size(); i++) { + a[i] = (static_cast(a[i - 1]) * 2 - a[p[i - 1]]) % mod; + b[i] = (static_cast(b[i - 1]) * 2 - b[p[i - 1]] - 2) % mod; + } + + cout << (mod - (static_cast(b[s.size() - 1]) * binpow(a[s.size() - 1], mod - 2)) % mod) % mod << endl; + + return 0; +} diff --git a/S2OJ/1731/data/monkey1.in b/S2OJ/1731/data/monkey1.in new file mode 100644 index 00000000..04c24490 --- /dev/null +++ b/S2OJ/1731/data/monkey1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a73373589418b8f34d61695882f0d209c621247c313ef145dd7a390baac6c8a6 +size 6 diff --git a/S2OJ/1731/data/monkey1.out b/S2OJ/1731/data/monkey1.out new file mode 100644 index 00000000..d64af66b --- /dev/null +++ b/S2OJ/1731/data/monkey1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2115cdb6bfcfb008eb2bab2bb79347cb064a48e4e7c4115ccbe4469c787bb6c4 +size 3 diff --git a/S2OJ/1731/data/monkey10.in b/S2OJ/1731/data/monkey10.in new file mode 100644 index 00000000..0bea14a6 --- /dev/null +++ b/S2OJ/1731/data/monkey10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1abeb6b9f8af289596446bb2120d2d35f53096bcadbbe001c9675d85891b4567 +size 1000001 diff --git a/S2OJ/1731/data/monkey10.out b/S2OJ/1731/data/monkey10.out new file mode 100644 index 00000000..184adba1 --- /dev/null +++ b/S2OJ/1731/data/monkey10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eb8720b92e4f6af60841cc77dfe6ef7229c821922119b28f5e7fbeaff3399fe8 +size 10 diff --git a/S2OJ/1731/data/monkey2.in b/S2OJ/1731/data/monkey2.in new file mode 100644 index 00000000..d12c134c --- /dev/null +++ b/S2OJ/1731/data/monkey2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d9b17274982f7b55a7c3f8728de738e1bf997ffde4efe3d0f227c41e64e8e194 +size 8 diff --git a/S2OJ/1731/data/monkey2.out b/S2OJ/1731/data/monkey2.out new file mode 100644 index 00000000..73d73dfb --- /dev/null +++ b/S2OJ/1731/data/monkey2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f5bde7eb9f6c71611dc5726e8aca3eb4eba3e386da49e0a4ed5c295a90a73a0d +size 4 diff --git a/S2OJ/1731/data/monkey3.in b/S2OJ/1731/data/monkey3.in new file mode 100644 index 00000000..a7c98553 --- /dev/null +++ b/S2OJ/1731/data/monkey3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b8e29307a5cf8d3bfddb1389a7144974d98743ba801796ffe728b1e2e47c6eb6 +size 21 diff --git a/S2OJ/1731/data/monkey3.out b/S2OJ/1731/data/monkey3.out new file mode 100644 index 00000000..ba3664a8 --- /dev/null +++ b/S2OJ/1731/data/monkey3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ce5742575e1378203b2de154c338a8932e251a4a897e99bc4dc49ed4aea54266 +size 8 diff --git a/S2OJ/1731/data/monkey4.in b/S2OJ/1731/data/monkey4.in new file mode 100644 index 00000000..584a1dfc --- /dev/null +++ b/S2OJ/1731/data/monkey4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36111fa816825631c2e6747929424407e5fc20635ae125afbc857a31245c398a +size 26 diff --git a/S2OJ/1731/data/monkey4.out b/S2OJ/1731/data/monkey4.out new file mode 100644 index 00000000..78eb9063 --- /dev/null +++ b/S2OJ/1731/data/monkey4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:58a256fb0325d6a3a3c006fc9f2a504ae85cefeeb8f7cf622948f5833df0ac49 +size 9 diff --git a/S2OJ/1731/data/monkey5.in b/S2OJ/1731/data/monkey5.in new file mode 100644 index 00000000..440f8513 --- /dev/null +++ b/S2OJ/1731/data/monkey5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:449f68ee4b0f77c9512c1737e5bc1014f189782183156088207185409746efa2 +size 501 diff --git a/S2OJ/1731/data/monkey5.out b/S2OJ/1731/data/monkey5.out new file mode 100644 index 00000000..119f828e --- /dev/null +++ b/S2OJ/1731/data/monkey5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8044ba2490f5cfe3975f23b402f2f30418727cd994e8db60e2b4923a4e09b79d +size 10 diff --git a/S2OJ/1731/data/monkey6.in b/S2OJ/1731/data/monkey6.in new file mode 100644 index 00000000..515b2f20 --- /dev/null +++ b/S2OJ/1731/data/monkey6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b8aa02971ec228ad1875aecea3aef06aa8526cb67b3f278ce06f3aeeb83118d3 +size 1001 diff --git a/S2OJ/1731/data/monkey6.out b/S2OJ/1731/data/monkey6.out new file mode 100644 index 00000000..41b6a3a8 --- /dev/null +++ b/S2OJ/1731/data/monkey6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca06a71f98e515007bad55a509cbde4d6dbcae7148d1abc58b65bd4b03c5a60e +size 10 diff --git a/S2OJ/1731/data/monkey7.in b/S2OJ/1731/data/monkey7.in new file mode 100644 index 00000000..340dc278 --- /dev/null +++ b/S2OJ/1731/data/monkey7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5019fc382d1e2c526a383b84ec523e26d847ce2972c4bc17d0c964a2504497cb +size 100001 diff --git a/S2OJ/1731/data/monkey7.out b/S2OJ/1731/data/monkey7.out new file mode 100644 index 00000000..ca711dd2 --- /dev/null +++ b/S2OJ/1731/data/monkey7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1542d6c13e385f7d227e720f031c8808ee5dd3636b6ccf7757fc0c49e98b6e9a +size 10 diff --git a/S2OJ/1731/data/monkey8.in b/S2OJ/1731/data/monkey8.in new file mode 100644 index 00000000..e85650a2 --- /dev/null +++ b/S2OJ/1731/data/monkey8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4cce6fbf3e5d419ee8820cab05eea7abf748e201962304b433186575a6da34d8 +size 100001 diff --git a/S2OJ/1731/data/monkey8.out b/S2OJ/1731/data/monkey8.out new file mode 100644 index 00000000..0118ea62 --- /dev/null +++ b/S2OJ/1731/data/monkey8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2bbc36aaedce0906322f042c5ccd2135ed26029aa01f852b6ed770086092c8fa +size 10 diff --git a/S2OJ/1731/data/monkey9.in b/S2OJ/1731/data/monkey9.in new file mode 100644 index 00000000..f6d16d15 --- /dev/null +++ b/S2OJ/1731/data/monkey9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7390ffc8988f545994a002b21df321e6e122ecca8ffc02a6e048a9db1569f550 +size 926529 diff --git a/S2OJ/1731/data/monkey9.out b/S2OJ/1731/data/monkey9.out new file mode 100644 index 00000000..6593ff58 --- /dev/null +++ b/S2OJ/1731/data/monkey9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eefc3da6f639c67e87b91fd8e222ba1afc8e9b5d6506d9618b4acad677b43a39 +size 10 diff --git a/S2OJ/1731/data/problem.conf b/S2OJ/1731/data/problem.conf new file mode 100644 index 00000000..752763c6 --- /dev/null +++ b/S2OJ/1731/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0bbf4104b78305c67b8fac234ff833dc26a4c269a4a01f43f886eca3b1cfdae4 +size 181