当前位置:网站首页>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;
}
边栏推荐
- psql 列转行
- 【移动端】手机界面的设计尺寸
- [day 26] given the ascending array nums of n elements, find a function to find the subscript of target in nums | learn binary search
- Processon producer process (customized)
- 疫情防控,居家办公,网上授课之心得 | 社区征文
- 常用的软件测试工具清单,请查收。
- Is it out of reach to enter Ali as a tester? Here may be the answer you want
- Test / development programmers, 30, do you feel confused? And where to go
- 字符串数组转换为list集合
- 【FPGA】串口以命令控制温度采集
猜你喜欢

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

DDD concept is complex and difficult to understand. How to design code implementation model in practice?

【STL源码剖析】STL六大组件功能与运用(目录)

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

Are programmers from Huawei, Alibaba and other large manufacturers really easy to find?

背了八股文,六月赢麻了……

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

Software testing salary in first tier cities - are you dragging your feet

软件测试人员的7个等级,据说只有1%的人能做到级别7

进入阿里做测试员遥不可及?这里或许有你想要的答案
随机推荐
入职一家新公司,如何快速熟悉代码?
vim的Dirvish中文文档
random list随机生成不重复数
Folding screen will become an important weapon for domestic mobile phones to share the apple market
Kaggle 专利匹配比赛金牌方案赛后总结
DDD概念复杂难懂,实际落地如何设计代码实现模型?
psql 列转行
【Proteus仿真】Arduino UNO+数码管显示4x4键盘矩阵按键
EasyCVR国标协议接入的通道,在线通道部分播放异常是什么原因?
Specific list of regular and safe domestic stock trading account opening
EasyCVR平台EHOME协议接入,视频播放出现断流是什么原因?
把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(3)—— 把数据库设置为归档模式
Stocking but not completely stocking (daily question 2 in spring)
Left hand dreams right hand responsibilities GAC Honda not only pays attention to sales but also children's safety
How to monitor the log through the easycvr interface to observe the platform streaming?
如何选择正规安全的外汇交易平台?
Constant current circuit composed of 2 NPN triodes
The role of software security testing, how to find a software security testing company to issue a report?
The ecosystem of the yuan universe
调用系统函数安全方案