当前位置:网站首页>【集训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;
}
边栏推荐
- 浅析接口测试
- 即刻报名|飞桨黑客马拉松第三期盛夏登场,等你挑战
- uni-app
- kaggle猫狗数据集开源——用于经典CNN分类实战
- On the growth of data technicians
- Common super easy to use regular expressions!
- 云渲染-体积云【理论基础与实现方案】
- 【虚拟机数据恢复】意外断电导致XenServer虚拟机不可用,虚拟磁盘文件丢失的数据恢复案例
- JS function scope variables declare that the variables that promote the scope chain without VaR are global variables
- 6-19漏洞利用-nsf获取目标密码文件
猜你喜欢

我们被一个 kong 的性能 bug 折腾了一个通宵

【OpenCV 例程 300篇】240. OpenCV 中的 Shi-Tomas 角点检测

Ascend target detection and recognition - customize your own AI application

Open source kaggle cat and dog data set -- used in classic CNN classification practice
2.1.2 synchronization always fails

Definition of graph traversal and depth first search and breadth first search (I)

(25) top level menu of blender source code analysis blender menu

Everything is available Cassandra: the fairy database behind Huawei tag

性能调优bug层出不穷?这3份文档轻松搞定JVM调优

大咖访谈 | 开源对安全是双刃剑——《大教堂与集市》中文译本作者卫剑钒
随机推荐
PIP installation module, error
Asemi rectifier bridge kbpc3510, kbpc3510 package, kbpc3510 application
【云原生之kubernetes实战】安装kubeopertor教程
即刻报名|飞桨黑客马拉松第三期盛夏登场,等你挑战
# MySQL 七种连接方式图解
Common super easy to use regular expressions!
JS closure simulates private variable interview questions and immediately executes function Iife
Pytest (mind map)
带你熟悉云网络的“电话簿”:DNS
浅谈数据技术人员的成长之路
Ascend target detection and recognition - customize your own AI application
Just this time! Talk about the technical solutions of distributed system in detail
kudu设计-tablet
Is the rolling update of pod similar to Canary deployment or blue-green deployment?
ASEMI整流桥KBPC2510,KBPC2510参数,KBPC2510规格书
常用超好用正则表达式!
Pytest(思维导图)
URL跳转漏洞
Asemi rectifier bridge kbpc2510, kbpc2510 parameters, kbpc2510 specifications
CCS TM4C123新建工程