From a73adcbea1a0b16c00c521c86d5dc656c02f2b3d Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 30 May 2022 19:21:20 +0800 Subject: [PATCH] P1879 [USACO06NOV]Corn Fields G https://www.luogu.com.cn/record/76684822 --- Luogu/P1879/P1879.cpp | 57 +++++++++++++++++++++++++++++++++ Luogu/P1879/data/cowfood.1.in | 3 ++ Luogu/P1879/data/cowfood.1.out | 3 ++ Luogu/P1879/data/cowfood.10.in | 3 ++ Luogu/P1879/data/cowfood.10.out | 3 ++ Luogu/P1879/data/cowfood.2.in | 3 ++ Luogu/P1879/data/cowfood.2.out | 3 ++ Luogu/P1879/data/cowfood.3.in | 3 ++ Luogu/P1879/data/cowfood.3.out | 3 ++ Luogu/P1879/data/cowfood.4.in | 3 ++ Luogu/P1879/data/cowfood.4.out | 3 ++ Luogu/P1879/data/cowfood.5.in | 3 ++ Luogu/P1879/data/cowfood.5.out | 3 ++ Luogu/P1879/data/cowfood.6.in | 3 ++ Luogu/P1879/data/cowfood.6.out | 3 ++ Luogu/P1879/data/cowfood.7.in | 3 ++ Luogu/P1879/data/cowfood.7.out | 3 ++ Luogu/P1879/data/cowfood.8.in | 3 ++ Luogu/P1879/data/cowfood.8.out | 3 ++ Luogu/P1879/data/cowfood.9.in | 3 ++ Luogu/P1879/data/cowfood.9.out | 3 ++ 21 files changed, 117 insertions(+) create mode 100644 Luogu/P1879/P1879.cpp create mode 100644 Luogu/P1879/data/cowfood.1.in create mode 100644 Luogu/P1879/data/cowfood.1.out create mode 100644 Luogu/P1879/data/cowfood.10.in create mode 100644 Luogu/P1879/data/cowfood.10.out create mode 100644 Luogu/P1879/data/cowfood.2.in create mode 100644 Luogu/P1879/data/cowfood.2.out create mode 100644 Luogu/P1879/data/cowfood.3.in create mode 100644 Luogu/P1879/data/cowfood.3.out create mode 100644 Luogu/P1879/data/cowfood.4.in create mode 100644 Luogu/P1879/data/cowfood.4.out create mode 100644 Luogu/P1879/data/cowfood.5.in create mode 100644 Luogu/P1879/data/cowfood.5.out create mode 100644 Luogu/P1879/data/cowfood.6.in create mode 100644 Luogu/P1879/data/cowfood.6.out create mode 100644 Luogu/P1879/data/cowfood.7.in create mode 100644 Luogu/P1879/data/cowfood.7.out create mode 100644 Luogu/P1879/data/cowfood.8.in create mode 100644 Luogu/P1879/data/cowfood.8.out create mode 100644 Luogu/P1879/data/cowfood.9.in create mode 100644 Luogu/P1879/data/cowfood.9.out diff --git a/Luogu/P1879/P1879.cpp b/Luogu/P1879/P1879.cpp new file mode 100644 index 00000000..2bdf9c76 --- /dev/null +++ b/Luogu/P1879/P1879.cpp @@ -0,0 +1,57 @@ +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 15, + M = 0xfff + 5; // = (11111111111)2 + 5 +const int mod = 1e8; + +int m, n, a[N], f[N][M], ans; +bool s[M]; + +int main() { + std::ios::sync_with_stdio(false); + + cin >> m >> n; + + for (int i = 1; i <= m; i++) { + for (int j = 1, x; j <= n; j++) { + cin >> x; + a[i] <<= 1; + a[i] += x; + } + } + + for (int i = 0; i < 0xfff; i++) { + // 行内不存在相邻的草地 + if (!((i << 1) & i) && !((i >> 1) & i)) { + s[i] = true; + } + } + + f[0][0] = 1; + for (int i = 1; i <= m; i++) { + // 当前行的状态 + for (int j = 0; j < 0xfff; j++) { + // j 是合法的状态,且没有草被种在贫瘠的土地上 + if (s[j] && (a[i] & j) == j) { + // 枚举上一行的状态 + for (int k = 0; k < 0xfff; k++) { + if (!(k & j)) { // k 和 j 间不存在相邻的土地 + f[i][j] = (f[i][j] + f[i - 1][k]) % mod; + } + } + } + } + } + + for (int i = 0; i < 0xfff; i++) { + ans = (ans + f[m][i]) % mod; + } + + cout << ans << endl; + + return 0; +} diff --git a/Luogu/P1879/data/cowfood.1.in b/Luogu/P1879/data/cowfood.1.in new file mode 100644 index 00000000..3d5b9461 --- /dev/null +++ b/Luogu/P1879/data/cowfood.1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:213be235f6dd1846dd4afea4ec038f8f0769b3c936e46ffbeda6bcef83b16144 +size 16 diff --git a/Luogu/P1879/data/cowfood.1.out b/Luogu/P1879/data/cowfood.1.out new file mode 100644 index 00000000..d790bd49 --- /dev/null +++ b/Luogu/P1879/data/cowfood.1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2e6d31a5983a91251bfae5aefa1c0a19d8ba3cf601d0e8a706b4cfa9661a6b8a +size 2 diff --git a/Luogu/P1879/data/cowfood.10.in b/Luogu/P1879/data/cowfood.10.in new file mode 100644 index 00000000..2cfdba14 --- /dev/null +++ b/Luogu/P1879/data/cowfood.10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c8922b433e0c58a18fd99ba5f4bacbb3f5247560eb2c203e7855cb8fa9027f20 +size 85 diff --git a/Luogu/P1879/data/cowfood.10.out b/Luogu/P1879/data/cowfood.10.out new file mode 100644 index 00000000..e79ddfe0 --- /dev/null +++ b/Luogu/P1879/data/cowfood.10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7feeb2b8a3e555bf0f785670b59335e67ab014c9cd077bdc183fe765e33b51fb +size 8 diff --git a/Luogu/P1879/data/cowfood.2.in b/Luogu/P1879/data/cowfood.2.in new file mode 100644 index 00000000..503905f0 --- /dev/null +++ b/Luogu/P1879/data/cowfood.2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:07e7bb7382f7ac8b8a679977251db73be6eccf8d6ac23363abd672bf5500156e +size 36 diff --git a/Luogu/P1879/data/cowfood.2.out b/Luogu/P1879/data/cowfood.2.out new file mode 100644 index 00000000..c5a137e9 --- /dev/null +++ b/Luogu/P1879/data/cowfood.2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:85a0e6eb5530a682fa88345a5e7a144248f49e5b71b3eb587a9db5cd2957495a +size 4 diff --git a/Luogu/P1879/data/cowfood.3.in b/Luogu/P1879/data/cowfood.3.in new file mode 100644 index 00000000..09205486 --- /dev/null +++ b/Luogu/P1879/data/cowfood.3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cf00f7c3cdde6edc22d7709bfb5e9861310c129eca22db4a6f68d013e22953dd +size 25 diff --git a/Luogu/P1879/data/cowfood.3.out b/Luogu/P1879/data/cowfood.3.out new file mode 100644 index 00000000..ef83284b --- /dev/null +++ b/Luogu/P1879/data/cowfood.3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9efe5a55840d37eb5db13a22ccab7e8f9867c982d1f7d18313c63fa0aa1c801b +size 4 diff --git a/Luogu/P1879/data/cowfood.4.in b/Luogu/P1879/data/cowfood.4.in new file mode 100644 index 00000000..4c3bc97c --- /dev/null +++ b/Luogu/P1879/data/cowfood.4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:908516a06a4532ef8c3708d1fb614131df17df5acd9dc1821abf7bb3b533af43 +size 6 diff --git a/Luogu/P1879/data/cowfood.4.out b/Luogu/P1879/data/cowfood.4.out new file mode 100644 index 00000000..1afab5f7 --- /dev/null +++ b/Luogu/P1879/data/cowfood.4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865 +size 2 diff --git a/Luogu/P1879/data/cowfood.5.in b/Luogu/P1879/data/cowfood.5.in new file mode 100644 index 00000000..1757a7b8 --- /dev/null +++ b/Luogu/P1879/data/cowfood.5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d1abfa41178a8e19636033a1d75b478859c96db268ee51cea3223e18bd8281a +size 64 diff --git a/Luogu/P1879/data/cowfood.5.out b/Luogu/P1879/data/cowfood.5.out new file mode 100644 index 00000000..524c7397 --- /dev/null +++ b/Luogu/P1879/data/cowfood.5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:84e836ee47ca37d2dd6ab579dc0f04992bf2b3981c63f5cad85ed605614a218e +size 6 diff --git a/Luogu/P1879/data/cowfood.6.in b/Luogu/P1879/data/cowfood.6.in new file mode 100644 index 00000000..53354b9b --- /dev/null +++ b/Luogu/P1879/data/cowfood.6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b701428615b8de92068ea1fa11268d162a517182451ae943911e54eb30eeaf05 +size 76 diff --git a/Luogu/P1879/data/cowfood.6.out b/Luogu/P1879/data/cowfood.6.out new file mode 100644 index 00000000..d6456893 --- /dev/null +++ b/Luogu/P1879/data/cowfood.6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:921cab4dd8bd56be04bea95b10a9d25eaeade78e2c888f18e721499bddcf8d71 +size 7 diff --git a/Luogu/P1879/data/cowfood.7.in b/Luogu/P1879/data/cowfood.7.in new file mode 100644 index 00000000..6e95d1c5 --- /dev/null +++ b/Luogu/P1879/data/cowfood.7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b313af3f0e85981ca00d9825f61400f3323a06e603825241d3604faf7e5cb51e +size 77 diff --git a/Luogu/P1879/data/cowfood.7.out b/Luogu/P1879/data/cowfood.7.out new file mode 100644 index 00000000..28a89d1a --- /dev/null +++ b/Luogu/P1879/data/cowfood.7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:be73e5778df50baf4779970cbec07012dea6aa2641677591fdf0c7054be75688 +size 7 diff --git a/Luogu/P1879/data/cowfood.8.in b/Luogu/P1879/data/cowfood.8.in new file mode 100644 index 00000000..a7cfac52 --- /dev/null +++ b/Luogu/P1879/data/cowfood.8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa05969c9f269be5a6f04b14a6e3030c434847ca98e9fd41b7f94ecd680a15dc +size 148 diff --git a/Luogu/P1879/data/cowfood.8.out b/Luogu/P1879/data/cowfood.8.out new file mode 100644 index 00000000..93565773 --- /dev/null +++ b/Luogu/P1879/data/cowfood.8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b1334eb441f1365d8e2601419c7637ddb4e96640d2a942a97f793f82b58901a5 +size 9 diff --git a/Luogu/P1879/data/cowfood.9.in b/Luogu/P1879/data/cowfood.9.in new file mode 100644 index 00000000..9c33873a --- /dev/null +++ b/Luogu/P1879/data/cowfood.9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:38b77d489fa5676f33d41ba1b4804951b953f7f3a925f98cf9ea6ec17f38f5a6 +size 132 diff --git a/Luogu/P1879/data/cowfood.9.out b/Luogu/P1879/data/cowfood.9.out new file mode 100644 index 00000000..3b497299 --- /dev/null +++ b/Luogu/P1879/data/cowfood.9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:74b12f26118525f00de1e0bf753c50719bb3d17ce85be2ea1871040faf68e833 +size 9