Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
标程Wa是个什么情况 http://ace.delos.com/TESTDATA/NOV06.cowfood.htm#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: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator