Dlsj is competing in a contest with n (0 < n \le 20)n(0<n≤20) problems. And he knows the answer of all of these problems.

However, he can submit ii-th problem if and only if he has submitted (and passed, of course) s_is
i
​ problems, the p_{i, 1}p
i,1
​ -th, p_{i, 2}p
i,2
​ -th, …, p_{i, s_i}p
i,s
i

​ -th problem before.(0 < p_{i, j} \le n,0 < j \le s_i,0 < i \le n)(0<p
i,j
​ ≤n,0<j≤s
i
​ ,0<i≤n) After the submit of a problem, he has to wait for one minute, or cooling down time to submit another problem. As soon as the cooling down phase ended, he will submit his solution (and get “Accepted” of course) for the next problem he selected to solve or he will say that the contest is too easy and leave the arena.

“I wonder if I can leave the contest arena when the problems are too easy for me.”
“No problem.”
—— CCF NOI Problem set

If he submits and passes the ii-th problem on tt-th minute(or the tt-th problem he solve is problem ii), he can get t \times a_i + b_it×a
i
​ +b
i
​ points. (|a_i|, |b_i| \le 10^9)(∣a
i
​ ∣,∣b
i
​ ∣≤10
9
).

Your task is to calculate the maximum number of points he can get in the contest.

Input
The first line of input contains an integer, nn, which is the number of problems.

Then follows nn lines, the ii-th line contains s_i + 3s
i
​ +3 integers, a_i,b_i,s_i,p_1,p_2,…,p_{s_i}a
i
​ ,b
i
​ ,s
i
​ ,p
1
​ ,p
2
​ ,…,p
s
i

​ as described in the description above.

Output
Output one line with one integer, the maximum number of points he can get in the contest.

Hint
In the first sample.

On the first minute, Dlsj submitted the first problem, and get 1 \times 5 + 6 = 111×5+6=11 points.

On the second minute, Dlsj submitted the second problem, and get 2 \times 4 + 5 = 132×4+5=13 points.

On the third minute, Dlsj submitted the third problem, and get 3 \times 3 + 4 = 133×3+4=13 points.

On the forth minute, Dlsj submitted the forth problem, and get 4 \times 2 + 3 = 114×2+3=11 points.

On the fifth minute, Dlsj submitted the fifth problem, and get 5 \times 1 + 2 = 75×1+2=7 points.

So he can get 11+13+13+11+7=5511+13+13+11+7=55 points in total.

In the second sample, you should note that he doesn’t have to solve all the problems.

样例输入1 复制
5
5 6 0
4 5 1 1
3 4 1 2
2 3 1 3
1 2 1 4
样例输出1 复制
55
样例输入2 复制
1
-100 0 0
样例输出2 复制
0
题目来源
ACM-ICPC 2018 南京赛区网络预赛

状压dp 即可;
( n<=20 )状压的标志

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#pragma GCC optimize("O3")
using namespace std;
#define maxn 100005
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
typedef long long  ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define sq(x) (x)*(x)
#define eps 1e-6
const int N = 2e7 + 5;
typedef pair<int, int> pii;inline int read()
{int x = 0, k = 1; char c = getchar();while (c < '0' || c > '9') { if (c == '-')k = -1; c = getchar(); }while (c >= '0' && c <= '9')x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();return x * k;
}ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a%b);
}int a[maxn], b[maxn];
vector<int>v[maxn];
int dp[1 << 20];int main()
{ios::sync_with_stdio(false);int n; cin >> n;int i, j, k;for (i = 1; i <= n; i++) {cin >> a[i] >> b[i];int tmp; cin >> tmp;while (tmp--) {int x; cin >> x; v[i].push_back(x);}}int flag = 0;for (i = 0; i < (1 << n); i++) {flag = 0;for (j = 1; j <= n; j++) {if ((1 << (j - 1)&i) == 0)continue;for (k = 0; k < v[j].size(); k++) {if ((1 << (v[j][k] - 1)&i) == 0) {flag = 1; break;}}if (flag)break;}if (flag)continue;for (j = 1; j <= n; j++) {if ((1 << (j - 1)&i) == 0)continue;int tot = 0, s = i;while (s) {if (s & 1)tot++; s >>= 1;}dp[i] = max(dp[i], dp[i ^ (1 << (j - 1))] + tot * a[j] + b[j]);}}cout << dp[(1 << n) - 1] << endl;return 0;
}

ACM-ICPC 2018 南京赛区网络预赛 AC Challenge相关推荐

  1. ACM-ICPC 2018 南京赛区网络预赛 - AC Challenge(状压DP)

    ACM-ICPC 2018 南京赛区网络预赛 - AC Challenge 题意: 有n个题目,每个题目有一些信息,,第 t 个过第 i 题会得到分数 t*ai + bi 在过第 i 题前必须要先过  ...

  2. ACM-ICPC 2018 南京赛区网络预赛 AC Challenge (状态压缩DP)

    题目链接 https://nanti.jisuanke.com/t/30994 题目大意 给出一些题目的价值参数a,b.答对这道题的价值为t×a+b,t是答对题目的数量(包括正在答的这道题).每道题不 ...

  3. ACM-ICPC 2018 南京赛区网络预赛 E-AC Challenge

    Dlsj is competing in a contest with n (0 < n ≤ 20) problems. And he knows the answer of all of th ...

  4. E. AC Challenge ACM-ICPC 2018 南京赛区网络预赛 状压dp + 枚举状态

    博客目录 原题 题目链接 Dlsj is competing in a contest with n (0 < n \le 20)n(0<n≤20) problems. And he kn ...

  5. ACM-ICPC 2018 南京赛区网络预赛 E AC Challenge(状压dp)

    Dlsj is competing in a contest with n (0 < n \le 20)n(0<n≤20) problems. And he knows the answe ...

  6. ACM-ICPC 2018 南京赛区网络预赛

    轻轻松松也能拿到区域赛名额,CCPC真的好难 An Olympian Math Problem 问答 只看题面 54.76% 1000ms 65536K Alice, a student of gra ...

  7. ACM-ICPC 2018 南京赛区网络预赛 Lpl and Energy-saving Lamps 线段树

    目录 ACM-ICPC 2018 南京赛区网络预赛 Lpl and Energy-saving Lamps 线段树 题面 题意 思路 ACM-ICPC 2018 南京赛区网络预赛 Lpl and En ...

  8. ACM-ICPC 2018 南京赛区网络预赛 B. The writing on the wall

    题目链接:https://nanti.jisuanke.com/t/30991 2000ms 262144K Feeling hungry, a cute hamster decides to ord ...

  9. L. Poor God Water(ACM-ICPC 2018 焦作赛区网络预赛,ac自动机+矩阵快速幂 或 BM线性递推)

    描述 God Water likes to eat meat, fish and chocolate very much, but unfortunately, the doctor tells hi ...

最新文章

  1. deepLink iOS 应用到自己APP 记录
  2. junit 测试目录_JUnit 5测试中的临时目录
  3. git与svn的区别 ?Git 与 SVN那个更好?
  4. 数据库基础知识——TCL语言
  5. word2003文档题注
  6. html选择树形菜单代码,jquery+css实现html选择树或树形菜单
  7. jquery代码小片段
  8. 简历javaweb项目描述怎么写_简历要怎么写
  9. 实验三 类和对象
  10. vs2010变的特别卡解决办法
  11. 新版jmeter图形化报告解析
  12. iOS支付宝支付总结
  13. linux卸载cognos,在Linux上实战安装Cognos
  14. c语言社交网络,【C++】设计并实现一种简单的社交网络模型图
  15. meterpreter_paranoid_mode.sh允许用户安全上演/无级连接Meterpreter经检查合格证书的处理程序正在连接到...
  16. 认知的高度 = 人生的高度
  17. 小陈java学习笔记0817
  18. BT5R3下安装metasploit
  19. 跳转Activity时,加入动画效果
  20. 浪潮信息做5G服务器,看来浪潮和运营商在5G布局非常深,中标移动开了个好头...

热门文章

  1. 著名演播艺术家艾宝良入驻讯飞阅读,人工智能助力声音传承
  2. jQuery - 获取兄弟元素
  3. 【数学建模常用模型】图论专题
  4. Python网络爬虫实战(四)模拟登录
  5. idea构建post请求_在IDEA中快速测试API接口
  6. 法国西南部发生火车追尾事故 已造成至少40人伤
  7. debussy vhdl co-simulation
  8. python音频 降噪_Python | 简单的扩音,音频去噪,静音剪切
  9. OverlayScrollbars插件监听滚动条的用法
  10. python画大耳朵图图_python之禅