2020杭电多校第二场 Lead of Wisdom(爆搜)
Problem Description
In an online game, “Lead of Wisdom” is a place where the lucky player can randomly get powerful items.
There are k types of items, a player can wear at most one item for each type. For the i-th item, it has four attributes ai,bi,ci and di. Assume the set of items that the player wearing is S, the damage rate of the player DMG can be calculated by the formula:
DMG=(100+∑i∈Sai)(100+∑i∈Sbi)(100+∑i∈Sci)(100+∑i∈Sdi)
Little Q has got n items from “Lead of Wisdom”, please write a program to help him select which items to wear such that the value of DMG is maximized.
Input
The first line of the input contains a single integer T (1≤T≤10), the number of test cases.
For each case, the first line of the input contains two integers n and k (1≤n,k≤50), denoting the number of items and the number of item types.
Each of the following n lines contains five integers ti,ai,bi,ci and di (1≤ti≤k, 0≤ai,bi,ci,di≤100), denoting an item of type ti whose attributes are ai,bi,ci and di.
Output
For each test case, output a single line containing an integer, the maximum value of DMG.
Sample Input
1
6 4
1 17 25 10 0
2 0 0 25 14
4 17 0 21 0
1 5 22 0 10
2 0 16 20 0
4 37 0 0 0
Sample Output
297882000
思路:
感觉没什么单调性,但是数据范围小,所以爆搜大约3^17可以水过,跑了6800ms。
赛中是每组随机去一个数,再随机很多次,每次随机一个数看替换掉能否更优,更优则替换,然后0ms过了。
这里爆搜唯一需要的剪枝是没有东西的分组一开始就不要考虑,否则每次dfs再特判很慢(这个我补的时候也没想到。。。看了题解发现了这个看似没有用的剪枝)。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<unordered_map>
#include <vector>
#include <map>using namespace std;
typedef long long ll;const int maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;struct Node {int a,b,c,d;
};vector<Node>vec[1005];
map<int,int>mp;
ll ans;
int n,k,cnt;ll get(Node num) {return 1ll * (100 + num.a) * (100 + num.b) * (100 + num.c) * (100 + num.d);
}void dfs(int x,Node num) {if(x > cnt) {ans = max(ans,get(num));return;}if(vec[x].size() == 0) dfs(x + 1,num);for(int i = 0;i < vec[x].size();i++) {Node now = vec[x][i];dfs(x + 1,{num.a + now.a,num.b + now.b,num.c + now.c,num.d + now.d});}
}int main() {int T;scanf("%d",&T);while(T--) {scanf("%d%d",&n,&k);for(int i = 1;i <= k;i++) vec[i].clear();mp.clear();cnt = 0;for(int i = 1;i <= n;i++) {int t,a,b,c,d;scanf("%d%d%d%d%d",&t,&a,&b,&c,&d);if(!mp[t]) {mp[t] = ++cnt;}vec[mp[t]].push_back({a,b,c,d});}ans = 0;dfs(1,{0,0,0,0});printf("%lld\n",ans);}return 0;
}
2020杭电多校第二场 Lead of Wisdom(爆搜)相关推荐
- 2022“杭电杯”中国大学生算法设计超级联赛 (2) 杭电多校第二场
题目 1001 Static Query on Tree AC代码 1002 C++ to Python AC代码 1003 Copy AC代码 1005 Slayers Come AC代码 1007 ...
- 20190724杭电多校第二场
没有补题..倒是又想到了1002的二分做法,比原来好写了不少,也快了不少. #include<bits/stdc++.h> using namespace std; #define p_b ...
- 2019杭电多校第二场1009 HDU6599:求本质不同的回文串长度及数量
hdu6599:求本质不同的回文串长度及数量 hdu6599题意: manacher+后缀自动机+倍增 $O(nlog(n))$ manacher+后缀数组+二分 $O(nlog(n))$ 回文树(回 ...
- 树形dp ---- 2018年杭电多校第二场 H travel
题目大意: 就是给你一个带点权的树,找到3条独立互不相交的路径使得权值和最大 解题思路: 很经典的树形dp 我们设dp[root][j][k]dp[root][j][k]dp[root][j][k]表 ...
- 2018杭电多校第二场1006(容斥原理,组合数学)
有能力时再回来解决吧= ̄ω ̄= 转载于:https://www.cnblogs.com/ldudxy/p/9521721.html
- 2022杭电多校第二场
1001 Static Query on Tree 题意:树上有A,B,C三个集合,求有多少个点在A某个点到C某个点的路径与A某个点到C某个点的路径的交上 把1到A集合中所有点的路径打上标记1,把1到 ...
- 2019年杭电多校第一场 1001题blank(DP)HDU6578
2019年杭电多校第一场 1001题blank(DP)HDU6578 解决思路,开一个DP数组来存储0 1 2 3四个字符最后出现的位置,并且在DP中已经==排好序==. DP开四维,DP[i][j] ...
- 2020杭电多校训练(第一、二场)
目录 第一场 1005.Fibonacci-Sum 1009.Leading-Robots 1006.Finding-a-MEX 第二场 1012.String-Distance 1005.New-E ...
- 2022“杭电杯”中国大学生算法设计超级联赛 (1) 杭电多校第一场 2 3 4 5 8 12
题目 1002 Dragon slayer 标程 1003 Backpack AC代码 1004 Ball AC代码 1008 Path AC代码 1009 Laser AC代码 1012 Alice ...
最新文章
- 程序员转型AI,这里有最全的机器学习介绍+应用实例
- 你知道Material Type(ROH,HALB,FERT…)为什么缩写是ROH,HALB,FERT吗?哈哈哈
- 计算机系统结构sw指令集,自考02325计算机系统结构复习资料六
- 使用TFHpple解析html
- 基于JAVA+SpringBoot+Mybatis+MYSQL的校园招聘管理系统
- 程序员吐槽:组里新来一个“加班狂”,可把大家害惨了
- PHP Cookbook读书笔记 – 第13章Web自动化
- javascript 浮点计算问题解决思路
- c语言a十六进制的地址,使用gdb调试c程序以显示十六进制地址
- Python学习第五弹【正则表达式】-kidult
- 软件是指示计算机运行所需的程序,计算机基础知识A.ppt
- 『TensorFlow』SSD源码学习_其四:数据介绍及TFR文件生成
- java对pdf分割_PDFBox分割PDF文档
- 战神引擎去右上角信息
- ABAP数据字典和数据表的读取
- Git-fatal: unable to access ‘https://gitlab.XX.git/‘: Could not resolve host: gitlab.XX.com.cn
- android 笔试题大全,2018年Android面试题大全
- javascript Xpath学习笔记-----document.evaluat();
- [C]你的n元一次常系数线性方程组解答小助手
- 求最大公因数的三种算法及简要说明