bzoj2460: [BeiJing2011]元素
生活随笔
收集整理的這篇文章主要介紹了
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
總結
以上是生活随笔為你收集整理的bzoj2460: [BeiJing2011]元素的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux移植之内核启动过程引导阶段分析
- 下一篇: 检查集群状态命令_轻松管理Kuberne