博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 3139 Balancing the Scale
阅读量:7082 次
发布时间:2019-06-28

本文共 1240 字,大约阅读时间需要 4 分钟。

枚举。

看了这个方法:$http://www.cppblog.com/shiming413/archive/2008/12/21/29671.html$

将数字归类的地方不能用$vector$,会超时。$vector$换成数组就可以过,类似于邻接表。

因为题目给出的$16$个数字都是不同的,所以时间复杂度相对还比较低。

下面这组数据是极限数据,我的跑了$3800$$ms$。但测试数据中不会出现这样的数据。

$5$ $5$ $5$ $5$ $5$ $5$ $5$ $5$ $5$ $5$ $5$ $5$ $5$ $5$ $5$

#pragma comment(linker, "/STACK:1024000000,1024000000")#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;typedef long long LL;const double pi=acos(-1.0),eps=1e-6;void File(){ freopen("D:\\in.txt","r",stdin); freopen("D:\\out.txt","w",stdout);}template
inline void read(T &x){ char c = getchar(); x = 0;while(!isdigit(c)) c = getchar(); while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); }}int a[20],b[20];LL h[(1<<16)+10];struct X{ int b, nx;}e[50000];int g[11000],k;void add(int a,int b){ e[k].b=b; e[k].nx=g[a]; g[a]=k++;}int main(){ int cas=1; while(~scanf("%d",&a[0])) { if(a[0]==0) break; for(int i=1;i<=15;i++) scanf("%d",&a[i]); k=0; memset(g,-1,sizeof g); for(int i=0;i<(1<<16);i++) { int t=i,cnt=0; for(int j=0;j<16;j++) if(i&(1<

 

转载于:https://www.cnblogs.com/zufezzt/p/5831556.html

你可能感兴趣的文章
react学习系列4 组件生命周期
查看>>
了解 php.ini
查看>>
异地容灾方案解析
查看>>
深入理解Vue的生命周期
查看>>
WPF's Style BasedOn
查看>>
.NET Core实战项目之CMS 第十章 设计篇-系统开发框架设计
查看>>
.NET服务安装、卸载、启动、停止、判断是否存在
查看>>
基于深度学习的推荐系统综述 (arxiv 1707.07435) 译文第一、二章
查看>>
自定义抖动表单
查看>>
CentOS 部署 MongoDB
查看>>
spring cloud互联网分布式微服务云平台规划分析--spring cloud定时调度平台
查看>>
[原译]Lambda高手之路第二部分
查看>>
Git Diff 插件配置
查看>>
vue的组件通信
查看>>
iOS开发之让列表滚回最顶端最佳实践
查看>>
让开发变得更简单 | 阿里云中间件推出全新开发者服务
查看>>
HTML与CSS布局技巧总结
查看>>
elk(日志监控系统搭建),elastic search,kibana,logstash,filebeat搭建
查看>>
现场剪光缆!ATEC上支付宝模拟自断一半服务器,26秒一切恢复正常
查看>>
世界上最流行的编程语言恰恰也是大多数黑客的首选武器
查看>>