diff --git a/S2OJ/1496/1496.cpp b/S2OJ/1496/1496.cpp new file mode 100644 index 00000000..3c39872a --- /dev/null +++ b/S2OJ/1496/1496.cpp @@ -0,0 +1,106 @@ +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 15; + +int n, t, a[N << 2], b[N << 2]; + +bool check() { + int cnt = 0; + + for (int i = 1; i <= 27; i++) { + if (b[i] < 0) return false; + if (b[i] >= 3) { + b[i] -= 3; + cnt++; + } + + if (i % 9 == 0 || i % 9 == 8) continue; + + while (b[i] > 0) { + b[i]--, b[i + 1]--, b[i + 2]--; + cnt++; + } + } + + return cnt == 4; +} + +bool check_hu() { + bool flag = false; + + for (int i = 1; i <= 27; i++) { + if (a[i] >= 2) flag = true; + } + + if (!flag) return false; + + for (int i = 1; i <= 27; i++) { + if (a[i] < 2) continue; + + std::copy_n(a, N << 2, b); + b[i] -= 2; + + if (check()) return true; + } + + return false; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n >> t; + + while (t--) { + std::fill_n(a, N << 2, 0); + + for (int i = 1; i <= n; i++) { + std::string s; + + cin >> s; + + int x = s[0] - '0'; + char c = s[1]; + + if (c == 'p') x += 9; + else if (c == 's') x += 18; + + a[x]++; + } + + if (n == 14) { + cout << check_hu() << endl; + } else { // n == 13 + for (int i = 1; i <= 27; i++) { + if (a[i] < 4) { + a[i]++; + + if (check_hu()) { + cout << (i - 1) % 9 + 1; + + if (1 <= i && i <= 9) { + cout << "m "; + } else if (10 <= i && i <= 18) { + cout << "p "; + } else { // 19 <= i && i <= 27 + cout << "s "; + } + } + + a[i]--; + } + } + + cout << endl; + } + } + + return 0; +} diff --git a/S2OJ/1496/data/data1.in b/S2OJ/1496/data/data1.in new file mode 100644 index 00000000..d77b0a94 --- /dev/null +++ b/S2OJ/1496/data/data1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f43abe2ab95dcb27c97200f13c135d5bdb61831c3ef87d06139fe42f77becc9e +size 425 diff --git a/S2OJ/1496/data/data1.out b/S2OJ/1496/data/data1.out new file mode 100644 index 00000000..dbd9dbf5 --- /dev/null +++ b/S2OJ/1496/data/data1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d155d1de2a402012450ec77881cdbedc960984f572fab327787c582fee29c115 +size 20 diff --git a/S2OJ/1496/data/data10.in b/S2OJ/1496/data/data10.in new file mode 100644 index 00000000..10c342b1 --- /dev/null +++ b/S2OJ/1496/data/data10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b6903da8f628dfb89ef859d65dfeab2feb5d57b3a45603c178f1b24eea88353 +size 402 diff --git a/S2OJ/1496/data/data10.out b/S2OJ/1496/data/data10.out new file mode 100644 index 00000000..e6ecdcfc --- /dev/null +++ b/S2OJ/1496/data/data10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5182af466f0d198a303989f9d97d81139745c59a71ddccd767a2ea42517da36c +size 88 diff --git a/S2OJ/1496/data/data11.in b/S2OJ/1496/data/data11.in new file mode 100644 index 00000000..f4dec7f0 --- /dev/null +++ b/S2OJ/1496/data/data11.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3740e66cde69f40f6b0ac5de7c567f6016b58fc472ad51fe729f967fa89f3340 +size 427 diff --git a/S2OJ/1496/data/data11.out b/S2OJ/1496/data/data11.out new file mode 100644 index 00000000..3634437b --- /dev/null +++ b/S2OJ/1496/data/data11.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33a75db261a8851ea31a1002e5fc9733b8844a00d3b0608b7883e5d528253d57 +size 20 diff --git a/S2OJ/1496/data/data12.in b/S2OJ/1496/data/data12.in new file mode 100644 index 00000000..b046447a --- /dev/null +++ b/S2OJ/1496/data/data12.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92f1ca1646fec196b7a0426746369091b839b73b55928c20ce8bb35e0bbe2659 +size 436 diff --git a/S2OJ/1496/data/data12.out b/S2OJ/1496/data/data12.out new file mode 100644 index 00000000..e8fb5fc4 --- /dev/null +++ b/S2OJ/1496/data/data12.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d39c577de4da621e16f28df7d9b1bf69e219eae6c9bfcd49d5a1d0e56d2dbf63 +size 20 diff --git a/S2OJ/1496/data/data13.in b/S2OJ/1496/data/data13.in new file mode 100644 index 00000000..a19230f0 --- /dev/null +++ b/S2OJ/1496/data/data13.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d9f5f1386d81163b6b7a82d91fb12bb40df82135708914528ee85d6e48c8e152 +size 425 diff --git a/S2OJ/1496/data/data13.out b/S2OJ/1496/data/data13.out new file mode 100644 index 00000000..6b2e8c0e --- /dev/null +++ b/S2OJ/1496/data/data13.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:51ced559c77461368432fbe834a4f21f04b80604e7028948bcf4cbc94a8eec76 +size 20 diff --git a/S2OJ/1496/data/data14.in b/S2OJ/1496/data/data14.in new file mode 100644 index 00000000..0d515065 --- /dev/null +++ b/S2OJ/1496/data/data14.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c273b554f1557b1b2d045672413a5037d685d721320a1a51e1456271571e47df +size 425 diff --git a/S2OJ/1496/data/data14.out b/S2OJ/1496/data/data14.out new file mode 100644 index 00000000..73d77ed2 --- /dev/null +++ b/S2OJ/1496/data/data14.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aff183c957a34f9935b27ba6f63b87e80a9a2ea4655f7025d98b512a0fb7bb3e +size 20 diff --git a/S2OJ/1496/data/data15.in b/S2OJ/1496/data/data15.in new file mode 100644 index 00000000..e8818dc9 --- /dev/null +++ b/S2OJ/1496/data/data15.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9504a31b23764e3fc0ccaf53d46ece5d2017fa2b1d72d1af0a127c3207a233a1 +size 430 diff --git a/S2OJ/1496/data/data15.out b/S2OJ/1496/data/data15.out new file mode 100644 index 00000000..c6940b93 --- /dev/null +++ b/S2OJ/1496/data/data15.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7e1d9c6ff19a09ec26cd9086d51fc51e1e1d827424908bf05167b9dbe56e5b94 +size 20 diff --git a/S2OJ/1496/data/data16.in b/S2OJ/1496/data/data16.in new file mode 100644 index 00000000..69f680ae --- /dev/null +++ b/S2OJ/1496/data/data16.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:09a02814f83632a603e8352bd99e429d2afa3637491440090ee484cd75205e44 +size 426 diff --git a/S2OJ/1496/data/data16.out b/S2OJ/1496/data/data16.out new file mode 100644 index 00000000..73176d97 --- /dev/null +++ b/S2OJ/1496/data/data16.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3abfb55e78a63f9506d4357da3e0dcfa06ec03e64d7dbe07e0abaa739a9478ed +size 20 diff --git a/S2OJ/1496/data/data17.in b/S2OJ/1496/data/data17.in new file mode 100644 index 00000000..afbbbcc8 --- /dev/null +++ b/S2OJ/1496/data/data17.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f99fc2e766ecbcce4f0c6d4f996af4cdf7800a7bee43843e2bd8cda157d00f6a +size 429 diff --git a/S2OJ/1496/data/data17.out b/S2OJ/1496/data/data17.out new file mode 100644 index 00000000..7f03c707 --- /dev/null +++ b/S2OJ/1496/data/data17.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e7521286c1e89bc9e1bcb6a96ff0c297dc89dc0d9e814d2500e6a264afbc425d +size 20 diff --git a/S2OJ/1496/data/data18.in b/S2OJ/1496/data/data18.in new file mode 100644 index 00000000..4c3a69ef --- /dev/null +++ b/S2OJ/1496/data/data18.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:326d3e9bc9a640f85ba1a7b6edfd43014c872db67d9427dcdce2648424d71791 +size 436 diff --git a/S2OJ/1496/data/data18.out b/S2OJ/1496/data/data18.out new file mode 100644 index 00000000..28602211 --- /dev/null +++ b/S2OJ/1496/data/data18.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:458bf39924572d43ecbb94f5c1b5982c30e812e2710dd75e515fc2ff6a10476e +size 20 diff --git a/S2OJ/1496/data/data19.in b/S2OJ/1496/data/data19.in new file mode 100644 index 00000000..994b5a85 --- /dev/null +++ b/S2OJ/1496/data/data19.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a34a28c3898040874a36030c8754899fd8a1acaf8d72c7d6bb9b59a8c0a9da95 +size 436 diff --git a/S2OJ/1496/data/data19.out b/S2OJ/1496/data/data19.out new file mode 100644 index 00000000..c4805ba9 --- /dev/null +++ b/S2OJ/1496/data/data19.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3717d398f81447eb4dd25204acc8fa40a89fc2091e0cadafa798fd67921a669f +size 20 diff --git a/S2OJ/1496/data/data2.in b/S2OJ/1496/data/data2.in new file mode 100644 index 00000000..449f3620 --- /dev/null +++ b/S2OJ/1496/data/data2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c295f4ff848f10904af1bfe8a9705f3ec940979e94865f8f128ba628f5ba7653 +size 397 diff --git a/S2OJ/1496/data/data2.out b/S2OJ/1496/data/data2.out new file mode 100644 index 00000000..1e412681 --- /dev/null +++ b/S2OJ/1496/data/data2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:05163516b312762ecad5e1983faad6dce30d066f0a54bd6b13c0b900c4487a0b +size 73 diff --git a/S2OJ/1496/data/data20.in b/S2OJ/1496/data/data20.in new file mode 100644 index 00000000..8b7c3009 --- /dev/null +++ b/S2OJ/1496/data/data20.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dc32441d01196d5383a0a1d8ee974baffb8ad9474d9eacbcf9e77bd4b64a90a7 +size 400 diff --git a/S2OJ/1496/data/data20.out b/S2OJ/1496/data/data20.out new file mode 100644 index 00000000..6fa5187d --- /dev/null +++ b/S2OJ/1496/data/data20.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b598189384069495e9a692d1725db6ddb8fd5aedb27d20f9a955ac5db433a343 +size 67 diff --git a/S2OJ/1496/data/data21.in b/S2OJ/1496/data/data21.in new file mode 100644 index 00000000..9ea89d8b --- /dev/null +++ b/S2OJ/1496/data/data21.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:983eda5142caef4248ecf2e6903a702bf06cb036158a47e5cafc97da3eabf07e +size 406 diff --git a/S2OJ/1496/data/data21.out b/S2OJ/1496/data/data21.out new file mode 100644 index 00000000..79eac1e8 --- /dev/null +++ b/S2OJ/1496/data/data21.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:576f35842a4a78f0269841be9a4e27bec2bf4b764859137281a88bc5e1fd77bf +size 55 diff --git a/S2OJ/1496/data/data22.in b/S2OJ/1496/data/data22.in new file mode 100644 index 00000000..f6da9d42 --- /dev/null +++ b/S2OJ/1496/data/data22.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c4e13b24d63d5259b3b2b05dafe52aae8206921be31381208c4b4f83495f862a +size 406 diff --git a/S2OJ/1496/data/data22.out b/S2OJ/1496/data/data22.out new file mode 100644 index 00000000..f9f6801f --- /dev/null +++ b/S2OJ/1496/data/data22.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5d3e461943983784fce29c689811a51f982a22ee02fe6f1c45ef4c664b05f210 +size 64 diff --git a/S2OJ/1496/data/data23.in b/S2OJ/1496/data/data23.in new file mode 100644 index 00000000..47d99239 --- /dev/null +++ b/S2OJ/1496/data/data23.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cbf3f834dfd2166c4cfd40a9849f994a236588f4f598c292d122fe1156fde7de +size 395 diff --git a/S2OJ/1496/data/data23.out b/S2OJ/1496/data/data23.out new file mode 100644 index 00000000..193536ad --- /dev/null +++ b/S2OJ/1496/data/data23.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0737edcd2b61c0f07f9392894b89328d24e196f7a4c429777908e5817312fa03 +size 61 diff --git a/S2OJ/1496/data/data24.in b/S2OJ/1496/data/data24.in new file mode 100644 index 00000000..22fa919d --- /dev/null +++ b/S2OJ/1496/data/data24.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b69c853d8441db754c0df99b3e34d91c2cb6e05868d0a6ec5e3c9b78792b65e2 +size 406 diff --git a/S2OJ/1496/data/data24.out b/S2OJ/1496/data/data24.out new file mode 100644 index 00000000..684a3180 --- /dev/null +++ b/S2OJ/1496/data/data24.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d03881db45100216916623e75c7a1afb301b0c26e47e03bdde75392659973457 +size 55 diff --git a/S2OJ/1496/data/data25.in b/S2OJ/1496/data/data25.in new file mode 100644 index 00000000..4d4a0464 --- /dev/null +++ b/S2OJ/1496/data/data25.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c3392f38c13c45d2786e1b2379d24a0691971aef6f57e341ee0d6cff86965b7 +size 406 diff --git a/S2OJ/1496/data/data25.out b/S2OJ/1496/data/data25.out new file mode 100644 index 00000000..bc50ea97 --- /dev/null +++ b/S2OJ/1496/data/data25.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92b021b6bc1e44f37f3cfefa638616178980fe009e14d4e462cff3bfeff42d21 +size 67 diff --git a/S2OJ/1496/data/data3.in b/S2OJ/1496/data/data3.in new file mode 100644 index 00000000..0bcaf2ea --- /dev/null +++ b/S2OJ/1496/data/data3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f35fec2e397cfb7b818d31ff0823d3d0f326302f15191ce99b79691333435093 +size 408 diff --git a/S2OJ/1496/data/data3.out b/S2OJ/1496/data/data3.out new file mode 100644 index 00000000..dbac204b --- /dev/null +++ b/S2OJ/1496/data/data3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6c8680c03945c303b564445483e6cf59745492495224ddcd8bd7f62090cb6d5 +size 100 diff --git a/S2OJ/1496/data/data4.in b/S2OJ/1496/data/data4.in new file mode 100644 index 00000000..3cd1b3f8 --- /dev/null +++ b/S2OJ/1496/data/data4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53f4b9a4e5ba8664961fbe6170c460a1d7f01705250cb067e108347312c6fd14 +size 426 diff --git a/S2OJ/1496/data/data4.out b/S2OJ/1496/data/data4.out new file mode 100644 index 00000000..de8f83ca --- /dev/null +++ b/S2OJ/1496/data/data4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f3dfe23ee24463b3647b27f84b130842bae66f50a63101f1f920a22980581363 +size 20 diff --git a/S2OJ/1496/data/data5.in b/S2OJ/1496/data/data5.in new file mode 100644 index 00000000..2680e846 --- /dev/null +++ b/S2OJ/1496/data/data5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2a7d5cbdf33f41ed8777de91e83d9ecb61925da0d59dc9fba8f7fd68c7ca2a0f +size 401 diff --git a/S2OJ/1496/data/data5.out b/S2OJ/1496/data/data5.out new file mode 100644 index 00000000..ee03476e --- /dev/null +++ b/S2OJ/1496/data/data5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:245ec308980479dcc77c99fd22db816429b00db4d3bae4911503f77e7ab6924e +size 103 diff --git a/S2OJ/1496/data/data6.in b/S2OJ/1496/data/data6.in new file mode 100644 index 00000000..33a4c2aa --- /dev/null +++ b/S2OJ/1496/data/data6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6c418a8411cb69b07154aaf976422b7b837dce2ae26e31bba3c2a7270df8ae0 +size 401 diff --git a/S2OJ/1496/data/data6.out b/S2OJ/1496/data/data6.out new file mode 100644 index 00000000..d28aff1d --- /dev/null +++ b/S2OJ/1496/data/data6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e001a81d3abf3a088a28359fb8384e27746e75069b6560de5b89c2d2f7a2888 +size 100 diff --git a/S2OJ/1496/data/data7.in b/S2OJ/1496/data/data7.in new file mode 100644 index 00000000..cbe273b2 --- /dev/null +++ b/S2OJ/1496/data/data7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:32089d08f54a867cf84901ea756e6d12acfcb831f59959376afe5f5309b3e3ad +size 399 diff --git a/S2OJ/1496/data/data7.out b/S2OJ/1496/data/data7.out new file mode 100644 index 00000000..130ad45c --- /dev/null +++ b/S2OJ/1496/data/data7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d3f28541b850289945b19bc4ba186a42596611acf7a3184acc519cb650b5f447 +size 115 diff --git a/S2OJ/1496/data/data8.in b/S2OJ/1496/data/data8.in new file mode 100644 index 00000000..c38dff7f --- /dev/null +++ b/S2OJ/1496/data/data8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0839ad83f84dccd02370c7ec3dff86a6fd13b56207826ebc8644332533cbe0c7 +size 403 diff --git a/S2OJ/1496/data/data8.out b/S2OJ/1496/data/data8.out new file mode 100644 index 00000000..1556f443 --- /dev/null +++ b/S2OJ/1496/data/data8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4f0405eaa8456cb299942f2ebfd784d3a58c2201de9b7e784071de532fc5a206 +size 94 diff --git a/S2OJ/1496/data/data9.in b/S2OJ/1496/data/data9.in new file mode 100644 index 00000000..7a5efc75 --- /dev/null +++ b/S2OJ/1496/data/data9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9eff077e81471d81c210e319f53e1030b649f61d563698a41fde402e1422a9c2 +size 402 diff --git a/S2OJ/1496/data/data9.out b/S2OJ/1496/data/data9.out new file mode 100644 index 00000000..f81298e0 --- /dev/null +++ b/S2OJ/1496/data/data9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12129d35fb3062a12be40adbd77fe4971a4e8c3690a80102de8ff62d597cab52 +size 133 diff --git a/S2OJ/1496/data/problem.conf b/S2OJ/1496/data/problem.conf new file mode 100644 index 00000000..9f744c1e --- /dev/null +++ b/S2OJ/1496/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6153605f797875f21525b107bb03f43d4ff62acb213f3b329123a04d1611d4c6 +size 177