P1896 [SCOI2005] 互不侵犯 (状压dp

#include 
using namespace std;
using VI = vector;
using PII = pair;
using ll = long long;
using ull = unsigned long long;
int n,k;
int cnt[1<<10];
ll f[12][100][1<<12];
int check(int x){

    if( !(x&x>>1) && !(x & x<<1)) return 1;
    else return 0;
}

int count_1(int x){
    int res = 0;
    while(x){
        res += (x & 1);
        x = x>>1;
    }
    return res;
}

int ff(int x,int y){
    if( !(x & y>>1)  && !(x & y<<1) && !(x & y))return 1;

    return 0;

}

int main(){
    cin>>n>>k;
    VI state;
    for(int i=0;i<=(1<=cnt[x]) f[i][j][x] += f[i-1][j-cnt[x]][y];
                }
            }
        }

    }
    //cout<

水题大概

你可能感兴趣的:(dp,算法)