考场上空间开大了一倍就爆0了QAQ…

#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn = 21;
int height[30], pos[30];
long long dp[1 << maxn][21];
int main()
{
int n, delta;
scanf("%d%d",&n,&delta);
for(int i = 1;i <= n + 1; ++i) pos[i] = (1 << (i - 1)) ;
for(int i = 1;i <= n; ++i) scanf("%d",&height[i]);
for(int i = 1;i <= n; ++i) dp[pos[i]][i] = 1;
for(int i = 1;i < pos[n + 1]; ++i)
{
for(int j = 1;j <= n; ++j)
{
if((i & pos[j]) == 0) continue;
int mx = i ^ pos[j];
if(mx == 0) continue;
for(int k = 1;k <= n; ++k)
{
if( (i & pos[k]) == 0 || k == j || abs(height[j] - height[k]) <= delta) continue;
dp[i][j] += dp[mx][k];
}
}
}
long long fin = 0;
for(int i = 1;i <= n; ++i) fin += dp[pos[n + 1] - 1][i];
printf("%lld",fin);
return 0;
}

  

最新文章

  1. CocoaPods被卡住:Updating local specs repositories
  2. 通过Iframe在A网站页面内嵌入空白页面的方式,跨域获取B网站的数据返回给A网站!
  3. Jquery生成树 ztree
  4. (原创)jQuery Media Plugin-jQuery的网页媒体播放器插件的使用心得
  5. Python学习-day1
  6. Dedesql数据库类详解
  7. UE4 VR 模式下全屏解决办法
  8. vs.net_2003 下载 虽然是老古董了,但还是很有用的。
  9. PHP 解压zip文件的函数封装
  10. linux查看硬件环境
  11. 《A First Course in Probability》-chaper7-极限定理-强大数定理
  12. 64位windows8的 IIS运行32位COM组件报错的解决
  13. WCF遇到Oracle问题
  14. ASP.NET交互Rest服务接口(Jquery的Get与Post方式)
  15. classname 就是在css上添加类,然后js的类名等于
  16. kotlin 语言入门指南一
  17. Head First设计模式之工厂模式
  18. cordova build android Command failed with exit code EACCES
  19. inception_v2版本《Rethinking the Inception Architecture for Computer Vision》(转载)
  20. linux 内存使用情况详解

热门文章

  1. Javase范式
  2. TensorFlow+实战Google深度学习框架学习笔记(10)-----神经网络几种优化方法
  3. POJ 2395 Out of Hay( 最小生成树 )
  4. ACM成长之路
  5. [洛谷 P1967] 货车运输 (最大生成树 lca)
  6. JAVA基础知识复习小结
  7. HDU5130 Signal Interference
  8. Core Dataeasy出现的错误
  9. 升级后开机就提示“android.process.acore”停止执行 --分析 解决方式
  10. linux下jenkins安装