bzoj2460: [BeiJing2011]元素

怕不是学了个假的线性基。。。一直以为要高位到低位插入,结果那个是高斯消元的线性基。。。

那么直接排序权值就行了。

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
typedef long long LL;struct node{LL num;int d;}a[1100];
bool cmp(node n1,node n2){return n1.d>n2.d;}
LL lt[110];int ans;
void insert(LL k)
{for(int i=62;i>=0;i--)if(a[k].num&(1LL<<i)){if(lt[i]==0){lt[i]=a[k].num;ans+=a[k].d;return ;}else a[k].num^=lt[i];}
}int main()
{int n;scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%lld%d",&a[i].num,&a[i].d);sort(a+1,a+n+1,cmp);ans=0;for(int i=1;i<=n;i++)insert(i);printf("%d\n",ans);return 0;
}

 

转载于:https://www.cnblogs.com/AKCqhzdy/p/9408049.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/279717.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

西湖论剑WP

先水几句&#xff0c;这次的题确实难啊&#xff0c;动用洪荒之力了&#xff0c;第一名的神仙也没有全部做完。 官方说这次的题目有两道没被做出来&#xff0c;我猜应该是PWN和RE吧 本来我们是45名的&#xff0c;最后5分钟那帮人啊&#xff0c;硬生生给我们挤出前50&#xff0c;…

vm macos 启用3d_如何在macOS中启用夜班以减轻眼睛疲劳

vm macos 启用3dNight Shift is a new feature introduced in macOS Sierra 10.12.4, and you might already be familiar with it if you’re an iOS user. Here’s how to enable it and set it up on your Mac. Night Shift是macOS Sierra 10.12.4中引入的新功能&#xff0c…

hdu3072 Intelligence System (最小树形图?)

题意&#xff1a;给一个有向图&#xff0c;问要从0号点能到达所有点所需要经过路径的最小权值和是多少&#xff0c;然而&#xff0c;若两点强联通&#xff0c;则这两点互相到达不需要花费。保证0号点能到达所有点 tarjan缩点以后直接取每个点入边中花费最小的即可。 1 #include…

如何在Windows 7、8、10,Vista或XP中删除Windows服务

If you are a fan of tweaking your system and disabling services, you might find that over time your Windows Services list becomes large and unwieldy. It’s easy enough to delete a Windows service using the Command Prompt. 如果您喜欢调整系统并禁用服务&#…

缩点(有向图的强连通分量)学习笔记

缩点(有向图的强连通分量)学习笔记 1.什么是强连通分量&#xff1f;&#xff1a; 有向图强连通分量:在有向图G中&#xff0c;如果两个顶点vi,vj间(vi>vj)有一条从vi到vj的有向路径&#xff0c;同时还有一条从vj到vi的有向路径&#xff0c;则称两个顶点强连通(strongly conne…

mysql多表联合删除

文件一&#xff1a;01.txt文件二&#xff1a;02.txt登录mysql选择数据库表user结构表user_depart结构导入数据到表user导入数据到表user_depart联合删除查看删除后user表的数据查看删除后user_depart表的数据本文转自 Lee_吉 51CTO博客&#xff0c;原文链接:http://blog.51cto.…

Jenkins 随笔

window是 随笔 修改端口 &#xff1a; <arguments>-Xrs -Xmx256m -Dhudson.lifecyclehudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort8181 --webroot"%BASE%\war"</arguments> 然后重启服务&#xff08;服务…

centos 初学者_初学者:如何在Outlook 2013中创建和管理任务

centos 初学者If you’re one of those people who has a whiteboard or notepad with an ever-evolving to-do list, or your desk and monitors are adorned with Post-its reminding you of important events, then this the article for you. 如果您是拥有不断发展的待办事…

C语言基础(五)

一、字符串相关函数 1.gets()(输入字符串) 格式&#xff1a;gets(字符串)&#xff1b; (1)区别&#xff1a;gets(str)与scanf(“%s”,str) gets(str)允许输入的字符串含有空格 scanf(“%s”,str)不允许含有空格 注意&#xff1a;由于以上无法知道字符串大小&#xff0c;很容易导…

新服务器安装和配置zabbix的playbook

公司的金山区云服务器是由我负责的&#xff0c;每一次新购买了金山区的服务器都要把这些新服务器添加到zabbix监控里&#xff0c;于是我就编写了一个ansible的playbook&#xff0c;这样以后就可以在执行playbook的时候“带薪拉屎”了。 ansible主机准备&#xff1a; 1&#xff…

15个变态的Google面试题以及答案

在当前经济形势不景气的情况下&#xff0c;谷歌招聘新员工是一件令人振奋的事&#xff0c;特别是对那些在当前金融风暴中渴望找到安全港的年轻经理们和软件开发商们来说是个好消息。   不过&#xff0c;也不要高兴太早&#xff0c;谷歌在招聘新员工时&#xff0c;更加青睐名牌…

小程序禁用ios 左右滑动_如何在使用应用程序时禁用iOS控制中心

小程序禁用ios 左右滑动The Control Center has proven to be a thoughtful and welcome addition to iOS, but it can be annoying sometimes if you’re playing a game or using an app, and you accidentally open it. Here’s how you can disable it in such situations.…

repomd.xml错误14 not found

用Centos7最小化安装了系统&#xff0c;想练练手&#xff0c;可以到换了“搜狐”的YUM源&#xff0c;系统总报错更新错误说找不到repomd.xml。 然后就一直搜解决问题&#xff0c;能用到的都用到了&#xff0c;网上提到的都用到了。浪费了好几个小时没解决。正当无语的时候&…

浅谈javascript递归(白话版)

递归 递归是一种解决问题的方法&#xff0c;通常我们可以理解成函数调用自身&#xff1b; 什么递归&#xff1f;递归怎么写&#xff1f; 首先直接调用自身的方法和函数&#xff0c;他是一个递归&#xff0c;我们看代码&#xff1a; 复制代码 var recursiveFun function(params…

超链接禁用_如何在Microsoft Word中禁用超链接

超链接禁用When you type a web or email address in Word, you may notice that the program automatically formats it as a live hyperlink. This is a setting in Word’s AutoFormat feature that is on by default but can be easily turned off. 当您在Word中键入网站或…

ssh面试题总结

题目1&#xff1a;Hibernate工作原理及为什么要用&#xff1f; 原理&#xff1a; hibernate&#xff0c;通过对jdbc进行封装&#xff0c;对 java类和 关系数据库进行mapping&#xff0c;实现了对关系数据库的面向对象方式的操作&#xff0c;改变了传统的jdbc sql操作数据的方式…

SaltStack的salt-ssh使用及LAMP状态设计部署

SaltStack的salt-ssh使用及LAMP状态设计部署 1、salt-ssh的使用 官方文档&#xff1a;https://docs.saltstack.com/en/2016.11/topics/ssh/index.html &#xff08;1&#xff09;安装salt-ssh [rootlinux-node1 ~]# yum install -y salt-ssh&#xff08;2&#xff09;配置salt-…

程序员笔记(知识)管理的一点经验

记笔记这件事&#xff0c;也许在很多人看来&#xff0c;再普通、简单不过了——从小老师就教育我们要这么做。不同的人有不同的方式&#xff0c;我们最终的目的&#xff0c;还是希望不要停留在只是记录这一层面上&#xff0c;而是将它们转变为我们的知识。作为一个程序员&#…

xbox可以录视频声音吗_什么是Xbox Live Gold,它值得吗?

xbox可以录视频声音吗If you have an Xbox One or Xbox 360, Microsoft’s Xbox Live Gold service is required to play multiplayer games online. A subscription costs $10 per month or $60 per year. Xbox Live Gold also includes additional benefits, like free games…

windows - mysql

Windows:(mysql)操作:0.下载安装mysql www.mysql.org downloads community 5.7.21 下载5.6 Microsoft Windows 解压到C: C:\mysql-5.6.39-winx64 C:\mysql-5.6.39-winx64\bin bin/mysql 客户端 bin/mysqld 服务端 设置环境变量: …