diff --git a/S2OJ/965/965.cpp b/S2OJ/965/965.cpp new file mode 100644 index 00000000..ad115c68 --- /dev/null +++ b/S2OJ/965/965.cpp @@ -0,0 +1,69 @@ +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = (18 << 1) + 5; + +int n; +long long ans; +bool vis[N]; +std::string s; +std::unordered_map map; + +void dfs1(int x) { + if (x == n + 1) { + std::string s1, s2; + + for (int i = 1; i <= n; i++) { + (vis[i] ? s2 : s1).push_back(s[i]); + } + + map[s1 + ' ' + s2]++; + + return; + } + + dfs1(x + 1); + vis[x] = true; + dfs1(x + 1); + vis[x] = false; +} + +void dfs2(int x) { + if (x == n * 2 + 1) { + std::string s1, s2; + + for (int i = n + n; i > n; i--) { + (vis[i] ? s2 : s1).push_back(s[i]); + } + + ans += map[s1 + ' ' + s2]; + + return; + } + + dfs2(x + 1); + vis[x] = true; + dfs2(x + 1); + vis[x] = false; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n >> s; + + s = ' ' + s; + + dfs1(1); + dfs2(n + 1); + + cout << (ans >> 1) << endl; + + return 0; +} diff --git a/S2OJ/965/data/problem.conf b/S2OJ/965/data/problem.conf new file mode 100644 index 00000000..7f39841f --- /dev/null +++ b/S2OJ/965/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5128ceb5ac094243d7468331843200823c4db340717d5d36821304674c67a9ad +size 212 diff --git a/S2OJ/965/data/string1.in b/S2OJ/965/data/string1.in new file mode 100644 index 00000000..dca697d9 --- /dev/null +++ b/S2OJ/965/data/string1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d7c06942bedff289f2d926a72a5016ac97ccedb7c4c4cb35d75ba4e3ddd93c52 +size 11 diff --git a/S2OJ/965/data/string1.out b/S2OJ/965/data/string1.out new file mode 100644 index 00000000..06d04c2c --- /dev/null +++ b/S2OJ/965/data/string1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa67a169b0bba217aa0aa88a65346920c84c42447c36ba5f7ea65f422c1fe5d8 +size 2 diff --git a/S2OJ/965/data/string10.in b/S2OJ/965/data/string10.in new file mode 100644 index 00000000..13b190af --- /dev/null +++ b/S2OJ/965/data/string10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:786a9612afb9e475fea66738483b5a7aa4672c2cb71673a273a17f2733320237 +size 38 diff --git a/S2OJ/965/data/string10.out b/S2OJ/965/data/string10.out new file mode 100644 index 00000000..0d671b4a --- /dev/null +++ b/S2OJ/965/data/string10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a1d86cc4635160525f3803b81e9e64844bbf25391c7bd8252862bdca06877379 +size 11 diff --git a/S2OJ/965/data/string11.in b/S2OJ/965/data/string11.in new file mode 100644 index 00000000..cdf78574 --- /dev/null +++ b/S2OJ/965/data/string11.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:59eaec6cd97dfa4693936e0f7e4ef4633c2219d6d2994995734fa54882731919 +size 34 diff --git a/S2OJ/965/data/string11.out b/S2OJ/965/data/string11.out new file mode 100644 index 00000000..f69b1e1a --- /dev/null +++ b/S2OJ/965/data/string11.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cabba8868134db37c0a2dda9893ceed2ffc73ca14171bed532bb62867eb47260 +size 8 diff --git a/S2OJ/965/data/string12.in b/S2OJ/965/data/string12.in new file mode 100644 index 00000000..78eca4a2 --- /dev/null +++ b/S2OJ/965/data/string12.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5f724b9d044651ee90a5bf8872f7177c22d8ce3a7a403e533d4c2cabef181ff0 +size 36 diff --git a/S2OJ/965/data/string12.out b/S2OJ/965/data/string12.out new file mode 100644 index 00000000..187a1289 --- /dev/null +++ b/S2OJ/965/data/string12.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:748ea33db356501af68a9e37a1583cfa57192a894aab2a692c5475f031d1e81a +size 4 diff --git a/S2OJ/965/data/string13.in b/S2OJ/965/data/string13.in new file mode 100644 index 00000000..5140a813 --- /dev/null +++ b/S2OJ/965/data/string13.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:402183381c2cd20c0bc03bd1a887620aa8ece6b7cac4cda4223925fc05ab4f0c +size 40 diff --git a/S2OJ/965/data/string13.out b/S2OJ/965/data/string13.out new file mode 100644 index 00000000..a6c27354 --- /dev/null +++ b/S2OJ/965/data/string13.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f531e6ee55622130665677e63dfa6c02da5fd749433bb6cc33f3dfd39756d5c6 +size 10 diff --git a/S2OJ/965/data/string14.in b/S2OJ/965/data/string14.in new file mode 100644 index 00000000..0afea859 --- /dev/null +++ b/S2OJ/965/data/string14.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3a920757d83a60a23fb58b893ada7b8677b89c6f103ce317993cccacb03239f8 +size 36 diff --git a/S2OJ/965/data/string14.out b/S2OJ/965/data/string14.out new file mode 100644 index 00000000..be5412b9 --- /dev/null +++ b/S2OJ/965/data/string14.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:df54c8eb930eaeb684bf915c7c01c81ea19e29ea46b7a37b3f58dac2e5330acd +size 9 diff --git a/S2OJ/965/data/string15.in b/S2OJ/965/data/string15.in new file mode 100644 index 00000000..588d54e8 --- /dev/null +++ b/S2OJ/965/data/string15.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fc2b205512fc119172df89a7400217ad292213667b9df86f2f8efb643a869571 +size 38 diff --git a/S2OJ/965/data/string15.out b/S2OJ/965/data/string15.out new file mode 100644 index 00000000..dab5f977 --- /dev/null +++ b/S2OJ/965/data/string15.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed1beed9c0ef9f386aa75b15068c1b6c3abc180e1cce072213ef9eaa57a33bc0 +size 8 diff --git a/S2OJ/965/data/string16.in b/S2OJ/965/data/string16.in new file mode 100644 index 00000000..4713c1d2 --- /dev/null +++ b/S2OJ/965/data/string16.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f4cf4164bc11d2c197bce7e99e6c02799ffcef1592bff29c3aabf4d46908d497 +size 40 diff --git a/S2OJ/965/data/string16.out b/S2OJ/965/data/string16.out new file mode 100644 index 00000000..62021f4d --- /dev/null +++ b/S2OJ/965/data/string16.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2a3e979450b9e31152e31cf837785aae9c3c5837e987c9bb11bfa70e31e93a4a +size 8 diff --git a/S2OJ/965/data/string17.in b/S2OJ/965/data/string17.in new file mode 100644 index 00000000..32960533 --- /dev/null +++ b/S2OJ/965/data/string17.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db5a09e066039bba786e6aa2cc19782ae70ad2b73c30bbcdc492e1c2f00d8547 +size 38 diff --git a/S2OJ/965/data/string17.out b/S2OJ/965/data/string17.out new file mode 100644 index 00000000..cba22bc7 --- /dev/null +++ b/S2OJ/965/data/string17.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6e3483fb2e518355f4439ffdc1ab70149dd1953daa6b89315bb47b1753b0d39b +size 8 diff --git a/S2OJ/965/data/string18.in b/S2OJ/965/data/string18.in new file mode 100644 index 00000000..8bf53fcb --- /dev/null +++ b/S2OJ/965/data/string18.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1ca5fe6e5e010029c8d8c11abb52a3487aa905f9a5268b448c785a9d0f69bcd2 +size 40 diff --git a/S2OJ/965/data/string18.out b/S2OJ/965/data/string18.out new file mode 100644 index 00000000..94324602 --- /dev/null +++ b/S2OJ/965/data/string18.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e5fa9bb0466d04e4d64530d8e77498b158705f75343bfafb68e66d7b5c4a8d32 +size 9 diff --git a/S2OJ/965/data/string19.in b/S2OJ/965/data/string19.in new file mode 100644 index 00000000..f4e0ee5a --- /dev/null +++ b/S2OJ/965/data/string19.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e5b8af26e7b4a76e82475bcefdecc13f03392b8424090f4f816e25eaf5e97729 +size 34 diff --git a/S2OJ/965/data/string19.out b/S2OJ/965/data/string19.out new file mode 100644 index 00000000..ccaf1d86 --- /dev/null +++ b/S2OJ/965/data/string19.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:80a9b13a8652664b1c757a79bd00a23b40c2b4a87327bf9cb7ab4e12db0123d8 +size 6 diff --git a/S2OJ/965/data/string2.in b/S2OJ/965/data/string2.in new file mode 100644 index 00000000..74bc7cf7 --- /dev/null +++ b/S2OJ/965/data/string2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:95811b4aada127de09bc9c29c96a368cd0fa82c78cb375f27e13eb9e18442986 +size 13 diff --git a/S2OJ/965/data/string2.out b/S2OJ/965/data/string2.out new file mode 100644 index 00000000..bf7021d6 --- /dev/null +++ b/S2OJ/965/data/string2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e6c21e8d260fe71882debdb339d2402a2ca7648529bc2303f48649bce0380017 +size 3 diff --git a/S2OJ/965/data/string20.in b/S2OJ/965/data/string20.in new file mode 100644 index 00000000..2a120b06 --- /dev/null +++ b/S2OJ/965/data/string20.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6dc294c622d424064ef4c1b0893ac920741cf5cdb5e1363cfded63f13ec9a3f1 +size 34 diff --git a/S2OJ/965/data/string20.out b/S2OJ/965/data/string20.out new file mode 100644 index 00000000..44179a33 --- /dev/null +++ b/S2OJ/965/data/string20.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33f50728129313570f6b953c08b559d9cb5f673e981e647cee4dc10d6cd48e99 +size 6 diff --git a/S2OJ/965/data/string21.in b/S2OJ/965/data/string21.in new file mode 100644 index 00000000..912c260e --- /dev/null +++ b/S2OJ/965/data/string21.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:34c017691640e3024d631310dd70b0664e46cfc5b694b3af9764f430ea51f6f8 +size 36 diff --git a/S2OJ/965/data/string21.out b/S2OJ/965/data/string21.out new file mode 100644 index 00000000..bc19eac8 --- /dev/null +++ b/S2OJ/965/data/string21.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de33640a0eb4eaa5ecd485dccb29eab8e5af8268c84edd0794b4c6a4acae7607 +size 6 diff --git a/S2OJ/965/data/string22.in b/S2OJ/965/data/string22.in new file mode 100644 index 00000000..461210f1 --- /dev/null +++ b/S2OJ/965/data/string22.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:883129b526ef25bbaa55e51db5f7dd60d2ce6e419a82033820c8d51c0666ff2c +size 38 diff --git a/S2OJ/965/data/string22.out b/S2OJ/965/data/string22.out new file mode 100644 index 00000000..ac9fce6a --- /dev/null +++ b/S2OJ/965/data/string22.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0f3633c0ecb81f7639c3fe70873b438e74fb8960c68f7c39e6a8eac795e70a32 +size 6 diff --git a/S2OJ/965/data/string23.in b/S2OJ/965/data/string23.in new file mode 100644 index 00000000..9e4249e6 --- /dev/null +++ b/S2OJ/965/data/string23.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91dc50958a5076d52048ec7f4ca538cdcd23b4eeb7149fe636b64f1900a796fd +size 40 diff --git a/S2OJ/965/data/string23.out b/S2OJ/965/data/string23.out new file mode 100644 index 00000000..6570d72e --- /dev/null +++ b/S2OJ/965/data/string23.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:38ea4bbef6fea8d73df79e1cfd9ee0e1e8aa44b963877e0285c6e892018cacda +size 7 diff --git a/S2OJ/965/data/string24.in b/S2OJ/965/data/string24.in new file mode 100644 index 00000000..3b76d839 --- /dev/null +++ b/S2OJ/965/data/string24.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a6b9da6106d05899dea8b85b2ded598ad11c30c8548b50238095919f3cdecbd6 +size 34 diff --git a/S2OJ/965/data/string24.out b/S2OJ/965/data/string24.out new file mode 100644 index 00000000..44179a33 --- /dev/null +++ b/S2OJ/965/data/string24.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33f50728129313570f6b953c08b559d9cb5f673e981e647cee4dc10d6cd48e99 +size 6 diff --git a/S2OJ/965/data/string25.in b/S2OJ/965/data/string25.in new file mode 100644 index 00000000..bb44ea62 --- /dev/null +++ b/S2OJ/965/data/string25.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b5e040f6c756b0fd52f2631373ceb47b02a043cb6594c13a140df0c59b30f8d +size 36 diff --git a/S2OJ/965/data/string25.out b/S2OJ/965/data/string25.out new file mode 100644 index 00000000..f4acaf8f --- /dev/null +++ b/S2OJ/965/data/string25.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d8f0b6f3a71ad9f8091974ddd43c066fb39796fa46f2c69ee629606ed407e6f0 +size 6 diff --git a/S2OJ/965/data/string3.in b/S2OJ/965/data/string3.in new file mode 100644 index 00000000..8882f432 --- /dev/null +++ b/S2OJ/965/data/string3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2051d7a910edb02bdb52a4a96f2c1ef08dbf2a24694cec3bdec04c85d5468851 +size 15 diff --git a/S2OJ/965/data/string3.out b/S2OJ/965/data/string3.out new file mode 100644 index 00000000..d64af66b --- /dev/null +++ b/S2OJ/965/data/string3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2115cdb6bfcfb008eb2bab2bb79347cb064a48e4e7c4115ccbe4469c787bb6c4 +size 3 diff --git a/S2OJ/965/data/string4.in b/S2OJ/965/data/string4.in new file mode 100644 index 00000000..358ff34c --- /dev/null +++ b/S2OJ/965/data/string4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:466a67b8d82281930bdcf85a43a5249aed5cc1022674efadf7e72e0d9d5d0e2a +size 17 diff --git a/S2OJ/965/data/string4.out b/S2OJ/965/data/string4.out new file mode 100644 index 00000000..c4217dfd --- /dev/null +++ b/S2OJ/965/data/string4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d93844f8f37e55564be3f194656bf33b5d0fb5e589a0fe17eb7c2d4e8593ec9c +size 3 diff --git a/S2OJ/965/data/string5.in b/S2OJ/965/data/string5.in new file mode 100644 index 00000000..d5e7a359 --- /dev/null +++ b/S2OJ/965/data/string5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4efdf00ba8713c059b5fe7c555c27e0d07c01f00a636f71928edc895ae0beae6 +size 19 diff --git a/S2OJ/965/data/string5.out b/S2OJ/965/data/string5.out new file mode 100644 index 00000000..1be038c9 --- /dev/null +++ b/S2OJ/965/data/string5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:56292515f7d3a7110811eb8de26b3f75f82a0766aa5a1fd66ebcfcb84fe6d5ff +size 4 diff --git a/S2OJ/965/data/string6.in b/S2OJ/965/data/string6.in new file mode 100644 index 00000000..ccedb7bd --- /dev/null +++ b/S2OJ/965/data/string6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f34327bb26537022232410a363ef92b839e871e0851f6b4f9d0b6597de0a7c95 +size 21 diff --git a/S2OJ/965/data/string6.out b/S2OJ/965/data/string6.out new file mode 100644 index 00000000..4bfd3a1f --- /dev/null +++ b/S2OJ/965/data/string6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f16c302d5d30e1d3fbe955cf4f637f58a871adeba597922e3baad0aeeb13f656 +size 4 diff --git a/S2OJ/965/data/string7.in b/S2OJ/965/data/string7.in new file mode 100644 index 00000000..1ca7c2a2 --- /dev/null +++ b/S2OJ/965/data/string7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:709ccbe82d732348cc30115693a7b7cd1d19d2fe218b66b0027353877c75d619 +size 24 diff --git a/S2OJ/965/data/string7.out b/S2OJ/965/data/string7.out new file mode 100644 index 00000000..4df899d0 --- /dev/null +++ b/S2OJ/965/data/string7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:240269e94afb4bbc4c643851e366bf4f0d870ff0753d250b854f748cf3516285 +size 4 diff --git a/S2OJ/965/data/string8.in b/S2OJ/965/data/string8.in new file mode 100644 index 00000000..92244ebd --- /dev/null +++ b/S2OJ/965/data/string8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0368bccb1f6113d53338545917b6c557ee4891f456238d48a26edfb88bf9609f +size 40 diff --git a/S2OJ/965/data/string8.out b/S2OJ/965/data/string8.out new file mode 100644 index 00000000..5d557862 --- /dev/null +++ b/S2OJ/965/data/string8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9431a7f22645352a348c85505f45f7a31239ff1a721a634143e4433715d34ccc +size 11 diff --git a/S2OJ/965/data/string9.in b/S2OJ/965/data/string9.in new file mode 100644 index 00000000..fc928e29 --- /dev/null +++ b/S2OJ/965/data/string9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c8059f6fc357fd2c87284f39eaf09799bd8d02df67266682f6ca5fba928f22a5 +size 36 diff --git a/S2OJ/965/data/string9.out b/S2OJ/965/data/string9.out new file mode 100644 index 00000000..554ec119 --- /dev/null +++ b/S2OJ/965/data/string9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1ded02a0a3c363ed8f185e94bad86dba12f6385e8db044dfa85f7e5ff2f7dbd9 +size 10