Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 标程Wa是个什么情况 http://ace.delos.com/TESTDATA/NOV06.cowfood.htm

Posted by ZxyElf at 2013-02-15 10:47:36 on Problem 3254
```#include <fstream>
#include <algorithm>
#include <vector>
#include <iterator>

using namespace std;

#define MAXR 12
#define MAXC 12
#define MAX2C (1 << MAXC)
#define MOD 100000000

int main() {
ifstream in("cowfood.in");
ofstream out("cowfood.out");
int infertile[MAXR + 1] = {0};
int dp[MAXR + 1][MAX2C];
int R, C, C2;
vector<int> valid;

in >> R >> C;
C2 = 1 << C;
fill(infertile, infertile + R, 0);
for (int i = 0; i < R; i++)
for (int j = 0; j < C; j++) {
int x;
in >> x;
if (!x) infertile[i + 1] |= 1 << j;
}

for (int i = 0; i < C2; i++)
if (!(i & (i << 1))) valid.push_back(i);

fill(dp[0], dp[0] + C2, 1);
for (int i = 1; i <= R; i++) {
fill(dp[i], dp[i] + C2, 0);
for (int j = 0; j < C2; j++) {
if (~j & infertile[i]) continue;
for (size_t k = 0; k < valid.size(); k++) {
int u = valid[k];
if (u & j) continue;
dp[i][j] += dp[i - 1][u | infertile[i - 1]];
dp[i][j] %= MOD;
}
}
}

out << dp[R][infertile[R]] << "\n";
return 0;
}
```

Followed by: