当前位置:网站首页>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;
}
边栏推荐
- Constant current circuit composed of 2 NPN triodes
- [live review] battle code pioneer phase 7: how third-party application developers contribute to open source
- mysql命令备份
- 内网学习笔记(6)
- tmux 如何自定义背景颜色 | How does the tmux color palette work?
- Integration of metersphere open source continuous testing platform and Alibaba cloud cloud cloud efficient Devops
- Please run IDA with elevated permissons for local debugging.
- Multimodal emotion recognition_ Research on emotion recognition based on multimodal fusion
- 测试/开发程序员,30而立,你是否觉得迷茫?又当何去何从......
- Computing service network: a systematic revolution of multi integration
猜你喜欢
随机推荐
如何卸载cuda
【Proteus仿真】Arduino UNO+继电器控制照明设备
把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(1)——迁移数据到节点1
File system - basic knowledge of disk and detailed introduction to FAT32 file system
random list随机生成不重复数
Please run IDA with elevated permissons for local debugging.
Convert string array to list collection
psql 列转行
【移动端】手机界面的设计尺寸
AI服装生成,帮你完成服装设计的最后一步
Android物联网应用程序开发(智慧园区)—— 设置传感器阈值对话框界面
业务与技术双向结合构建银行数据安全管理体系
当人们用互联网式的思维和视角来看待产业互联网的时候,其实已陷入到了死胡同
Basic layout -qhboxlayout class, qvboxlayout class, qgridlayout class
记一次beego通过go get命令后找不到bee.exe的坑
Redis
Viewing MySQL password on Linux_ MySQL forgets password "suggestions collection" under Linux
[day 26] given the ascending array nums of n elements, find a function to find the subscript of target in nums | learn binary search
Investigation on key threats of cloud computing applications in 2022
It's 2022, and you still don't know what performance testing is?









