P1879 Corn Fields G ( 壮鸭dp

#include 
using namespace std;
using VI = vector;
using PII = pair;
using ll = long long;
using ull = unsigned long long;
int n,m;
int f[20][1<<13];
int mp[110];
int cnt[1<<13];
const int mod = 100000000;
bool check(int x){
    //当前状态没有相邻的1
    if(!(x & x>>1)){
        return true;
    }
    return false;

}
int ff(int x,int y){

    while(x && y){
        if((x & 1) == 1 && (y & 1) == 1) return 0;
        x = x>>1;
        y = y>>1;
    }
    return 1;
}
int grass_st(int grass ,int st){
    while(grass || st){
        if((grass & 1) ==0 && (st & 1) == 1) return 0;
        grass = grass >>1;
        st = st>>1;
    }
    return 1;

}
int main(){
    cin>>m>>n;
    for(int i=1;i<=m;i++){
        int st = 0;
        for(int j=0;j>x;
            if(x) st |= (1<

感觉思维上好像难度不大,主要就是这个预处理合理状态得仔细想想

你可能感兴趣的:(dp,算法,数据结构)