0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 13:58:48 +00:00

#10171. 「一本通 5.4 例 2」牧场的安排

https://loj.ac/s/1472551
This commit is contained in:
Baoshuo Ren 2022-05-30 19:14:41 +08:00
parent f6e8e7b701
commit 577fe26b55
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
23 changed files with 123 additions and 0 deletions

57
LibreOJ/10171/10171.cpp Normal file
View File

@ -0,0 +1,57 @@
#include <iostream>
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;
}

BIN
LibreOJ/10171/data/cowfood.1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.9.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/10171/data/cowfood.out (Stored with Git LFS) Normal file

Binary file not shown.