当前位置:网站首页>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;
}
边栏推荐
- 谈谈飞书对开发工作的优势 | 社区征文
- Investigation on key threats of cloud computing applications in 2022
- Processon producer process (customized)
- Half of the year has passed. How many flags have been achieved at the end of the year?
- PE文件基础结构梳理
- 云原生数据库VS传统数据库
- 如何通过EasyCVR接口监测日志观察平台拉流情况?
- 一线城市软件测试工资——你拖后腿了吗
- 多模态情感识别_多模态融合的情感识别研究「建议收藏」
- Rod and Schwartz cooperated with ZhongGuanCun pan Lianyuan Institute to carry out 6G technology research and early verification
猜你喜欢

1-6搭建Win7虚拟机环境

当他们在私域里,掌握了分寸感

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

Redis 那些事

yarn : 无法加载文件 C:\Users\xxx\AppData\Roaming\npm\yarn.ps1,因为在此系统上禁止运行脚本

Pit entry machine learning: I. Introduction

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

What is the reason for the disconnection of video playback due to the EHOME protocol access of easycvr platform?

【STL源码剖析】配置器(待补充)

Redis
随机推荐
internship:svn的使用
Please run IDA with elevated permissons for local debugging.
vim的Dirvish中文文档
非凸联合创始人李佐凡:将量化作为自己的终身事业
DDD concept is complex and difficult to understand. How to design code implementation model in practice?
折叠屏将成国产手机分食苹果市场的重要武器
How to choose a regular and safe foreign exchange trading platform?
Lizuofan, co-founder of nonconvex: Taking quantification as his lifelong career
获取图片外链的方法–网易相册[通俗易懂]
Sumati GameFi生态纵览,神奇世界中的元素设计
如何选择正规安全的外汇交易平台?
Specific list of regular and safe domestic stock trading account opening
当人们用互联网式的思维和视角来看待产业互联网的时候,其实已陷入到了死胡同
做软件安全测试的作用,如何寻找软件安全测试公司出具报告?
3 years of testing experience. I don't even understand what I really need on my resume. I need 20K to open my mouth?
Explanation of FTP protocol
Intranet learning notes (5)
Are programmers from Huawei, Alibaba and other large manufacturers really easy to find?
|How to analyze bugs? Professional summary and analysis
如何卸载cuda