传送门

文章目录

  • 题意:
  • 思路:

题意:

你有nnn个装备槽,每个槽里面有cic_ici​个力量加成,对于每个槽只能选一个力量加成,现在给你mmm个力量组合[b1,b2,...,bn][b_1,b_2,...,b_n][b1​,b2​,...,bn​]代表这个力量组合是不能选择的。问你每个槽选择一个力量之后最大的的力量总和是多少。保证有解。

n≤10,1≤ci≤2e5n\le 10,1\le c_i\le 2e5n≤10,1≤ci​≤2e5

cic_ici​总和不超过2e52e52e5

思路:

可以知道,总共的情况就是∏i=1nci\prod_{i=1}^nc_i∏i=1n​ci​,由于有解,所以这个显然是大于mmm的,考虑暴力找状态。

一开始想了个假算法,就是每次找所有槽中值最小的,显然不对,考虑到m≤2e5m\le 2e5m≤2e5,所以如果我们直接从当前状态枚举nnn个槽去掉了一个状态,将这些状态压入队列中,一定可以找到最优解,但是队列显然会爆掉,考虑到当找到一个能取的集合,那么这个集合的子集合都没有用了,所以这个时候不需要扩展,而且会遍历到很多重复的集合,所以需要去重,所以这样直接搞就好了,复杂度我不是很会算。。

// Problem: D. The Strongest Build
// Contest: Codeforces - Educational Codeforces Round 114 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1574/problem/D
// Memory Limit: 256 MB
// Time Limit: 3000 ms
//
// Powered by CP Editor (https://cpeditor.org)//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//#pragma GCC optimize(2)
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<cmath>
#include<cctype>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#include<ctime>
#include<cstdlib>
#include<random>
#include<cassert>
#define X first
#define Y second
#define L (u<<1)
#define R (u<<1|1)
#define pb push_back
#define mk make_pair
#define Mid ((tr[u].l+tr[u].r)>>1)
#define Len(u) (tr[u].r-tr[u].l+1)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define db puts("---")
using namespace std;//void rd_cre() { freopen("d://dp//data.txt","w",stdout); srand(time(NULL)); }
//void rd_ac() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//AC.txt","w",stdout); }
//void rd_wa() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//WA.txt","w",stdout); }typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;const int N=1000010,mod=1e9+7,INF=0x3f3f3f3f;
const double eps=1e-6;int n,m;
int ed[20];
vector<int>v[20],ans;
set<pair<int,vector<int>>>s;
map<vector<int>,int>mp,st;int main()
{//  ios::sync_with_stdio(false);
//  cin.tie(0);scanf("%d",&n);for(int i=1;i<=n;i++) {int c; scanf("%d",&c);while(c--) {int x; scanf("%d",&x);v[i].pb(x);}}scanf("%d",&m);for(int i=1;i<=m;i++) {vector<int>v;for(int i=1;i<=n;i++) {int x; scanf("%d",&x);v.pb(x);}mp[v]=1;}  int sum=0;for(int i=1;i<=n;i++) ans.pb(v[i].size());queue<vector<int>>q;q.push(ans); int now=0;st[ans]=1;while(q.size()) {auto x=q.front(); q.pop();if(!mp.count(x)) {int all=0;for(int i=1;i<=n;i++) all+=v[i][x[i-1]-1];if(all>sum) sum=all,ans=x;continue;}for(int i=1;i<=n;i++) {if(x[i-1]>1) {x[i-1]--;if(st.count(x)) {x[i-1]++;continue;}q.push(x);st[x]=1;x[i-1]++;} }}for(auto x:ans) cout<<x<<' '; puts("");return 0;
}
/*
3 1 2 3
2 1 5
3 2 4 6
2
3 2 3
2 2 3
*/

Educational Codeforces Round 114 (Rated for Div. 2) D. The Strongest Build 暴力 + bfs相关推荐

  1. Educational Codeforces Round 114 (Rated for Div. 2) (A ~ F)全题解

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Educational Codeforces Round 114 (Rated for Div. 2) ...

  2. Educational Codeforces Round 114 (Rated for Div. 2)C. Slay the Dragon

    题目链接:Problem - 1574C - Codeforces Recently, Petya learned about a new game "Slay the Dragon&quo ...

  3. Educational Codeforces Round 114 (Rated for Div. 2) 个人题解

    中秋节快乐! A. Regular Bracket Sequences 题意 输出nnn个不同的长度为2n2n2n的合法括号序列. 分析 先输出一个"()()()-"序列. 然后依 ...

  4. 1574D The Strongest Build (Educational Codeforces Round 114 (Rated for Div. 2))

    题意 给定n个从小到大的数组,从每个数组中选出一个下标构成一个序列,但是有m种序列被ban了,要求选出的序列对应的数字和最大且没有被ban. 思路 因为有m个序列被ban了,那么最坏的情况可以假设为最 ...

  5. Educational Codeforces Round 106 (Rated for Div. 2)(A ~ E)题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 Educational Codeforces Round 106 (Rated for Div. ...

  6. Educational Codeforces Round 37 (Rated for Div. 2) 1

    Educational Codeforces Round 37 (Rated for Div. 2) A.Water The Garden 题意:Max想给花园浇水.花园可被视为长度为n的花园床,花园 ...

  7. Educational Codeforces Round 90 (Rated for Div. 2)(A, B, C, D, E)

    Educational Codeforces Round 90 (Rated for Div. 2) Donut Shops 思路 分三种情况: a==c/ba == c / ba==c/b这个时候两 ...

  8. Educational Codeforces Round 89 (Rated for Div. 2)(A, B, C, D)

    Educational Codeforces Round 89 (Rated for Div. 2) A. Shovels and Swords 思路 题意非常简单,就是得到最多的物品嘛,我们假定a, ...

  9. Educational Codeforces Round 72 (Rated for Div. 2) D. Coloring Edges dfs树/拓扑找环

    传送门 文章目录 题意: 思路: 题意: 给你一张图,你需要给这个图的边染色,保证如果有环那么这个环内边的颜色不全相同,输出染色方案和用的颜色个数. n,m≤5e3n,m\le5e3n,m≤5e3 思 ...

最新文章

  1. GBDT家族:GBDT家族成员的演进路劲、xgboost模型、lightGBM、LightGBM 相对于 XGBoost 的优点、catboost、xgboost、catboost、lightGBM对
  2. 性能测试工具MultiMechanize的使用介绍
  3. python语言是机器语言_Python解释器:源代码--字节码--机器语言
  4. 阿里巴巴消息中间件: Spring Cloud Stream
  5. javascript 保存原函数_前端工程师必须掌握的几个JavaScript设计模式及场景应用
  6. 基于DGCNN和概率图的三元组信息抽取模型
  7. 深度学习解决NLP问题:语义相似度计算
  8. scratch python转化_从Scratch到Python——Python生成二维码
  9. springboot模板项目搭建:代码生成器AutoGenerator
  10. 十分钟django后台 simpleui -含自定义后台首页
  11. 阿里妈妈返利比率的商品搜索API接口
  12. 贪心算法——皇后游戏(洛谷P2123)
  13. Kaggle教程 机器学习中级3 分类变量
  14. python派森编程软件_《派森》(Python)
  15. 内置在maven项目的服务器,IDEA使用maven中tomcat插件来启动服务器配置
  16. 腾讯云服务器如何重装系统
  17. 全面公测|Grafana服务:一张图表胜过千行指标日志
  18. djcpth计算机实验报告,计算机组成原理实验
  19. Methyltetrazine-DBCO,1802238-48-7该试剂可用于在无催化剂试剂的情况下,将含氮肽或蛋白质转化为四胺改性多肽或蛋白质
  20. 以NDN和IPFS为代表的ICN架构能为互联网带来什么

热门文章

  1. 基于文本知识库的强化学习技术——Learning to Win by Reading Manuals in a Monte-Carlo Framework
  2. 第4章 字符串和格式化输入/输出
  3. 【直观理解】为什么梯度的负方向是局部下降最快的方向?
  4. 代码传奇 | 明明可以靠颜值 却用代码把人类送上了月球的女人——Margaret Hamilton
  5. 面试常见问题_软件实施工程师面试中的常见问题都有哪些呢?
  6. mac mysql php_Mac搭建php开发环境:Apache+php+MySql
  7. 小甲鱼零基础入门python二十一课课后题_小甲鱼Python第二十一讲课后习题
  8. java threadsafe 注解_Java 注解详解
  9. 日历签到 java_我的Android案例―签到日历
  10. mysql双机互备linux成功的_配置MySQL双机热备 - Linux服务器MySQL双机热备份试验_数据库技术_Linux公社-Linux系统门户网站...