标签:getc style class bzoj problem define efi log ext
bzoj3446[Usaco2014 Feb]Cow Decathlon
题意:
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <queue> 5 #define inc(i,j,k) for(int i=j;i<=k;i++) 6 #define maxn 30 7 using namespace std; 8 9 inline int read(){ 10 char ch=getchar(); int f=1,x=0; 11 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1; ch=getchar();} 12 while(ch>=‘0‘&&ch<=‘9‘)x=x*10+ch-‘0‘,ch=getchar(); 13 return f*x; 14 } 15 int n,b,s[maxn][maxn],f[2][1500000],bit[1500000]; bool x,y; 16 struct nd{int p,a,n;}nds[maxn]; int g[maxn],tot; 17 int main(){ 18 n=read(); b=read(); 19 inc(i,1,b){int x=read(); nds[i].p=read(); nds[i].a=read(); nds[i].n=g[x]; g[x]=i;} 20 inc(i,1,n)inc(j,1,n)s[i][j]=read(); x=0; y=1; 21 inc(i,0,(1<<n)-1){bit[i]=0; inc(j,0,n-1)if(i&(1<<j))bit[i]++;} 22 inc(i,1,n){ 23 inc(j,0,(1<<n)-1)if(bit[j]==i){ 24 inc(l,1,n)if(j&(1<<(l-1)))f[y][j]=max(f[y][j],f[x][j&((1<<n)-1-(1<<(l-1)))]+s[l][i]); 25 for(int l=g[i];l;l=nds[l].n)if(f[y][j]>=nds[l].p)f[y][j]+=nds[l].a; 26 } 27 swap(x,y); 28 } 29 printf("%d",f[x][(1<<n)-1]); return 0; 30 }
20161116
bzoj3446[Usaco2014 Feb]Cow Decathlon*
标签:getc style class bzoj problem define efi log ext
原文地址:http://www.cnblogs.com/YuanZiming/p/6072308.html