当前位置:网站首页>F - spices (linear basis)
F - spices (linear basis)
2022-06-25 02:20:00 【Harris-H】
F - Spices( Linear base )
The conclusion is that [ 1 , 2 n − 1 ] [1,2^n-1] [1,2n−1] At most n n n Number can be expressed [ 1 , 2 n − 1 ] [1,2^n-1] [1,2n−1] , The principle is a linear basis .
Because of the demand v a l u e value value Minimum , So sort by value , Then simulate the linear basis .
Time complexity : O ( n 2 n ) O(n2^n) O(n2n)
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<std::pair<int, int>> a((1 << n) - 1);
for (int i = 0; i < (1 << n) - 1; i++) {
int x;
std::cin >> x;
a[i] = {
x, i + 1};
}
std::sort(a.begin(), a.end());
i64 ans = 0;
std::vector<int> t(n);
for (auto [v, x] : a) {
for (int i = 0; i < n; i++) {
if (x >> i & 1) {
if (t[i] == 0) {
ans += v;
t[i] = x;
break;
}
x ^= t[i];
}
}
}
std::cout << ans << "\n";
return 0;
}
边栏推荐
猜你喜欢

It's 2022, and you still don't know what performance testing is?

Sumati gamefi ecological overview, element design in the magical world

内网学习笔记(5)

EasyCVR国标协议接入的通道,在线通道部分播放异常是什么原因?

业务与技术双向结合构建银行数据安全管理体系

记一次beego通过go get命令后找不到bee.exe的坑
![[live review] battle code pioneer phase 7: how third-party application developers contribute to open source](/img/ad/26a302ca724177e37fe123f8b75e4e.png)
[live review] battle code pioneer phase 7: how third-party application developers contribute to open source

一线城市软件测试工资——你拖后腿了吗

What are the reasons for the abnormal playback of the online channel of the channel accessed by easycvr national standard protocol?

random list随机生成不重复数
随机推荐
Multimodal emotion recognition_ Research on emotion recognition based on multimodal fusion
Qt中使用QDomDocument操作XML文件
实战攻防演练中的四大特点
|How to analyze bugs? Professional summary and analysis
云原生数据库VS传统数据库
计算机三级(数据库)备考题目知识点总结
LINQ 查询(3)
常用的软件测试工具清单,请查收。
yarn : 无法加载文件 C:\Users\xxx\AppData\Roaming\npm\yarn.ps1,因为在此系统上禁止运行脚本
Sumati GameFi生态纵览,神奇世界中的元素设计
Cusdis - 轻量级、隐私优先的开源评论系统 | 倾城之链
把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(4)—— 修改 oracle11g rac 集群的 scanIP
Squid 代理服务器之 ACL 访问控制
ProcessOn制作ER过程(自定义)
元宇宙的生态圈
获取图片外链的方法–网易相册[通俗易懂]
Logminer database log mining
算力服务网络:一场多元融合的系统革命
如何通过EasyCVR接口监测日志观察平台拉流情况?
Test / development programmers, 30, do you feel confused? And where to go