bzoj3446[Usaco2014 Feb]Cow Decathlon*
bzoj3446[Usaco2014 Feb]Cow Decathlon
题意:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#define inc(i,j,k) for(int i=j;i<=k;i++)
#define maxn 30
using namespace std; inline int read(){
char ch=getchar(); int f=,x=;
while(ch<''||ch>''){if(ch=='-')f=-; ch=getchar();}
while(ch>=''&&ch<='')x=x*+ch-'',ch=getchar();
return f*x;
}
int n,b,s[maxn][maxn],f[][],bit[]; bool x,y;
struct nd{int p,a,n;}nds[maxn]; int g[maxn],tot;
int main(){
n=read(); b=read();
inc(i,,b){int x=read(); nds[i].p=read(); nds[i].a=read(); nds[i].n=g[x]; g[x]=i;}
inc(i,,n)inc(j,,n)s[i][j]=read(); x=; y=;
inc(i,,(<<n)-){bit[i]=; inc(j,,n-)if(i&(<<j))bit[i]++;}
inc(i,,n){
inc(j,,(<<n)-)if(bit[j]==i){
inc(l,,n)if(j&(<<(l-)))f[y][j]=max(f[y][j],f[x][j&((<<n)--(<<(l-)))]+s[l][i]);
for(int l=g[i];l;l=nds[l].n)if(f[y][j]>=nds[l].p)f[y][j]+=nds[l].a;
}
swap(x,y);
}
printf("%d",f[x][(<<n)-]); return ;
}
20161116
bzoj3446[Usaco2014 Feb]Cow Decathlon*的更多相关文章
- BZOJ 3446: [Usaco2014 Feb]Cow Decathlon( 状压dp )
		水状压dp. dp(x, s) = max{ dp( x - 1, s - {h} ) } + 奖励(假如拿到的) (h∈s). 时间复杂度O(n * 2^n) ------------------- ... 
- BZOJ_3448_[Usaco2014 Feb]Auto-complete_Trie树
		BZOJ_3448_[Usaco2014 Feb]Auto-complete_Trie Description Bessie the cow has a new cell phone and enjo ... 
- BZOJ1631: [Usaco2007 Feb]Cow Party
		1631: [Usaco2007 Feb]Cow Party Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 459 Solved: 338[Submit ... 
- BZOJ3301: [USACO2011 Feb] Cow Line
		3301: [USACO2011 Feb] Cow Line Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 67 Solved: 39[Submit ... 
- BZOJ1697: [Usaco2007 Feb]Cow Sorting牛排序
		1697: [Usaco2007 Feb]Cow Sorting牛排序 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 387 Solved: 215[S ... 
- BZOJ 1631: [Usaco2007 Feb]Cow Party( 最短路 )
		这道题和蔡大神出的今年STOI初中组的第二题几乎一模一样... 先跑一遍最短路 , 再把所有边反向 , 再跑一遍 , 所有点两次相加的最大值即为answer --------------------- ... 
- BZOJ 1631: [Usaco2007 Feb]Cow Party
		题目 1631: [Usaco2007 Feb]Cow Party Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 491 Solved: 362[Sub ... 
- 3301: [USACO2011 Feb] Cow Line
		3301: [USACO2011 Feb] Cow Line Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 82 Solved: 49[Submit ... 
- 3893: [Usaco2014 Dec]Cow Jog
		3893: [Usaco2014 Dec]Cow Jog Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 174 Solved: 87[Submit] ... 
随机推荐
- (二)JavaMail创建包含内嵌图片的邮件
			链接:https://blog.csdn.net/qq_41151659/article/details/96475739 代码如下: import com.sun.mail.util.MailSSL ... 
- C++中为什么按两次ctrl+D才能结束标准I/O
			参考资料: https://www.douban.com/group/topic/127062773/ 今天学习了C++语言的标准I/O,也就是std::cin和std::cout,但是我发现当系统在 ... 
- css3动画的实例讲解
			<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ... 
- 富文本插件tinymce初始化配置参数说明
			{ language: _this.language, // 显示语种 selector: #${_this.tinymceId}, // 容器的id height: _this.height, // ... 
- MonoBehaviour.StartCoroutine开启协同程序
			StartCoroutine协同程序 StartCoroutine(IEnumerator) StartCoroutine(string methodName) StartCoroutine(stri ... 
- 报错 version `GLIBCXX_3.4.22' not found
			from . import pypocketfft as pfft ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GL ... 
- eclipse 导入下载或拷贝的java Web项目时报错 ,或者是报错Unbound classpath container: 'JRE System Library
			在Problems里报错Description Resource Path Location Type Unbound classpath container: 'JRE System Library ... 
- Java工具类——数学相关的类
			Java工具类--数学相关的类 在上一篇文章中,我们系统学习了 Java 里面的包装类,那么这篇文章,我们就来学习一下Java提供好的类--数学相关的类. 一.数学类介绍 在最早期学习 Java 基础 ... 
- 基本 Docker 命令列表
			docker build -t friendlyname .# 使用此目录的 Dockerfile 创建镜像 docker run -p 4000:80 friendlyname # 运行端口 400 ... 
- 修改CentOS7登录欢迎界面信息
			vi /etc/issue 添加自己喜欢的内容,保存即可. 特殊字符的含义: \d 本地端时间的日期: \l 显示第几个终端机接口: \m 显示硬件的等级 (i386/i486/i586/i686.. ... 
