当前位置:网站首页>【集训Day2】Sculpture
【集训Day2】Sculpture
2022-07-26 16:55:00 【SSL_GYX】
Sculpture

解题思路
金典状压 D P DP DP,设 f i f_i fi 表示选取状态为 i i i 时的方案总数,枚举上一个选择的数 j j j 进行转移,动态转移方程为: f i = ∑ j ∈ i n f i − 1 < < j f_i=\sum^{n}_{j\in i}f_{i-1<<j} fi=j∈i∑nfi−1<<j\
code
#include<iostream>
#include<cstdio>
#define int long long
using namespace std;
int n,m;
int f[1<<21];
int a[30][30];
int g(int i)
{
int s=0;
while(i)
s+=i&1,i>>=1;
return s;
}
signed main()
{
cin>>n>>m;
for(int i=1;i<=m;i++)
{
int x,y;
scanf("%lld%lld",&x,&y);
a[x][y]=1;
}
f[0]=1;
for(int i=0;i<(1<<n);i++)
for(int j=0;j<n;j++)
if(i&(1<<j)&&!a[g(i)][j+1])
f[i]+=f[i-(1<<j)];
cout<<f[(1<<n)-1]<<endl;
}
边栏推荐
- Everything is available Cassandra: the fairy database behind Huawei tag
- TD database syntax
- About the adjustment of the game background, reading this article is enough
- Why are test / development programmers who are better paid than me? Abandoned by the times
- MySQL foundation - basic database operation
- API for sellers -- description of the return value of adding baby API to Taobao / tmall sellers' stores
- 2019 popularization group summary
- 一文详解吞吐量、QPS、TPS、并发数等高并发指标
- Comparison between dimensional modeling and paradigm modeling
- leetcode:1206. 设计跳表【跳表板子】
猜你喜欢

236. 二叉树的最近公共祖先

hosts该文件已设置为只读的解决方法

Avalanche subnets vs. polygon supernets of application chain

机器视觉在服务机器人中的应用
![[C language classic topic exercise 2]](/img/66/8dbfefe585aa35f5791f04b376b75c.png)
[C language classic topic exercise 2]

JS recursive Fibonacci sequence deep cloning

CCS tm4c123 new project

跨站脚本攻击(XSS)

ASEMI整流桥KBPC3510,KBPC3510封装,KBPC3510应用

Summer Challenge openharmony greedy snake based on JS
随机推荐
二层管理型交换机如何设置IP
What are the popular technologies in 2022?
如何快速使用 ELisp 进行插件编写
The diagram of user login verification process is well written!
即刻报名|飞桨黑客马拉松第三期盛夏登场,等你挑战
Performance tuning bugs emerge in endlessly? These three documents can easily handle JVM tuning
Asemi rectifier bridge kbpc2510, kbpc2510 parameters, kbpc2510 specifications
CCS tm4c123 new project
简述CUDA镜像构建
We were tossed all night by a Kong performance bug
kudu设计-tablet
6-19 vulnerability exploitation -nsf to obtain the target password file
After Australia, New Zealand announced the ban on Huawei 5g! Huawei official response
Application of machine vision in service robot
kaggle猫狗数据集开源——用于经典CNN分类实战
[cloud native] IVX low code development was introduced into Tencent map and previewed online
JS 闭包 模拟私有变量 面试题 立即执行函数IIFE
Environment setup mongodb
Week 4 Recurrent Neural Networks
uni-app