【CodeForces 417D】【Cunning Gena】
来源:互联网 发布:矩阵通解 编辑:程序博客网 时间:2024/05/17 04:20
http://codeforces.com/problemset/problem/417/D
看来最近智商真的是出了大问题了,英语也读不懂了、
//#define _TEST _TEST#include <cstdio>#include <cstring>#include <cstdlib>#include <iostream>#include <cmath>#include <algorithm>using namespace std;/************************************************Code By willinglive Blog:http://willinglive.cf************************************************/#define rep(i,l,r) for(int i=l,___t=(r);i<=___t;i++)#define per(i,r,l) for(int i=r,___t=(l);i>=___t;i--)#define MS(arr,x) memset(arr,x,sizeof(arr))#define LL long long#define INE(i,u,e) for(int i=head[u];~i;i=e[i].next)inline const int read(){int r=0,k=1;char c=getchar();for(;c<'0'||c>'9';c=getchar())if(c=='-')k=-1;for(;c>='0'&&c<='9';c=getchar())r=r*10+c-'0';return k*r;}/////////////////////////////////////////////////const LL inf=((unsigned LL)0-1)>>1;int n,m; LL b;struct data{LL k;int x;int s;}a[102];LL dp[1<<20],ans;int all;/////////////////////////////////////////////////bool cmp(data p,data q){return p.k<q.k;}void cal(int k){rep(S,0,all){dp[S|a[k].s]=min(dp[S|a[k].s],dp[S]+a[k].x);}ans=min(ans,dp[all]+a[k].k*b);}/////////////////////////////////////////////////void input(){ n=read(); m=read(); b=read(); rep(i,1,n) { a[i].x=read(); a[i].k=read(); rep(j,1,read()) a[i].s|=1<<read()-1; } sort(&a[1],&a[n+1],cmp);}void solve(){ MS(dp,0x3f); dp[0]=0; ans=((unsigned LL)0-1)>>1; all=1<<m; all--; rep(i,1,n) cal(i); if(ans<inf/3) printf("%I64d\n",ans); else puts("-1");}/////////////////////////////////////////////////int main(){ #ifndef _TEST freopen("std.in","r",stdin); freopen("std.out","w",stdout); #endif input(),solve(); return 0;}
0 0
- Codeforces 417 D. Cunning Gena
- 【CodeForces 417D】【Cunning Gena】
- codeforces 417D Cunning Gena
- CodeForces 417D Cunning Gena 状压dp
- COdeforces#417D Cunning Gena(状压DP)
- Codeforces 417D Cunning Gena(状态压缩dp)
- Codeforces 417D Cunning Gena【排序+状压dp】
- codefoces 417D Cunning Gena 状压DP
- [CF 417D]Cunning Gena:状压DP
- CF 417D - Cunning Gena--状态压缩DP
- CF 417D Cunning Gena [状压dp+排序]
- codeforces 418B. Cunning Gena (状态dp)
- RCC 2014 Warmup (Div. 2) D. Cunning Gena
- CF RCC 2014 Warmup (Div. 2) D. Cunning Gena
- CF RCC 2014 Warmup (Div. 2) D. Cunning Gena
- RCC 2014 Warmup (Div. 2) D. Cunning Gena(状压DP)
- CF417D--- Cunning Gena(排序+状压dp)
- CF417D——Cunning Gena(状态压缩DP)
- EQU
- 弹出层插件的编写-layer(跨iframe传值回调)
- 第七届中国R语言会议杭州会场开场致辞(阿里巴巴数据技术与产品部负责人闵万里)
- MFMessageComposeViewController 短信发送
- Android Intent 序列化和反序列化
- 【CodeForces 417D】【Cunning Gena】
- Delphi-- 如何设置程序开机运行(写注册表)
- Socat虚拟pty
- Android基础第九天易忘部分(加载大图片和缩放图片)
- oracle 的查询的执行顺序和一些方法
- RCP基本框架
- tp的代码生成器
- Android Studio如果老需要下载Grable下载怎么办?
- iOS开发者必备:六大图片、图标处理类工具