zoukankan      html  css  js  c++  java
  • Luogu1879 [USACO06NOV]玉米田Corn Fields (状压DP)

    曾经放弃的坑,都是坑

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    #define R(a,b,c) for(register int  a = (b); a <= (c); ++ a)
    #define nR(a,b,c) for(register int  a = (b); a >= (c); -- a)
    #define Max(a,b) ((a) > (b) ? (a) : (b))
    #define Min(a,b) ((a) < (b) ? (a) : (b))
    #define Fill(a,b) memset(a, b, sizeof(a))
    #define Abs(a) ((a) < 0 ? -(a) : (a))
    #define Swap(a,b) a^=b^=a^=b
    #define ll long long
    
    #define ON_DEBUG
    
    #ifdef ON_DEBUG
    
    #define D_e_Line printf("
    
    ----------
    
    ")
    #define D_e(x)  cout << #x << " = " << x << endl
    #define Pause() system("pause")
    #define FileOpen() freopen("inn.txt","r",stdin);
    
    #else
    
    #define D_e_Line ;
    #define D_e(x)  ;
    #define Pause() ;
    #define FileOpen() ;
    
    #endif
    
    struct ios{
        template<typename ATP>ios& operator >> (ATP &x){
            x = 0; int f = 1; char c;
            for(c = getchar(); c < '0' || c > '9'; c = getchar()) if(c == '-')  f = -1;
            while(c >= '0' && c <= '9') x = x * 10 + (c ^ '0'), c = getchar();
            x*= f;
            return *this;
        }
    }io;
    using namespace std;
    
    const int mod = 100000000;
    
    int F[13];
    int f[13][(1 << 12) + 7];
    int g[(1 << 12) + 7];
    
    int main(){
    	int m, n;
    	io >> n >> m;
    
        R(i,1,n){
            R(j,1,m){
                int x;
                io >> x;
                F[i] = (F[i] << 1) + x;
            }
        }
    
        R(i,0,(1 << m) - 1){
        	g[i] = (!(i & (i << 1))) && (!(i & (i >> 1)));
        }
    
        f[0][0] = 1;
        R(i,1,n){
            R(j,0,(1 << m) - 1){
                if(g[j] && ((j & F[i]) == j)) {
                    R(k,0,(1 << m) - 1){
                        if((k & j) == 0){
                            f[i][j] = (f[i][j] + f[i - 1][k]) % mod;
                        }
                    }
                }
            }
        }
    
        int ans = 0;
        R(i,0,(1 << m) - 1){
            ans = (ans + f[n][i]) % mod;
        }
        
        printf("%d
    ", ans);
        return 0;
    }
    

  • 相关阅读:
    elasticsearch 基础
    docker 安装ElasticSearch的中文分词器IK
    Netty的编解码,粘包拆包,心跳检测机制
    Spring IOC 常用的注解
    @JsonView的使用
    lombok的使用以及其中的坑
    Zuul的高级使用
    SpringBoot 整合 ActiveMq
    转:Maven <resource>标签
    码农经常读错的单词
  • 原文地址:https://www.cnblogs.com/bingoyes/p/11234615.html
Copyright © 2011-2022 走看看