标签:scanf nod code fine div beijing efi its href
//It is coded by Ning_Mew on 5.29
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn=1007;
int n;
LL A[maxn];
struct Node{
LL num;int val;
}s[maxn];
LL ans=0;
bool cmp(const Node &x,const Node &y){return x.val>y.val;}
bool check(int k){
bool kk=false;
for(int i=60;i>=0;i--){
if((s[k].num>>i)&1){
if(!A[i]){
A[i]=s[k].num; kk=true; break;
}else{
s[k].num=(s[k].num^A[i]);
}
}
}return kk;
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%lld%d",&s[i].num,&s[i].val);
}
sort(s+1,s+n+1,cmp);
for(int i=1;i<=n;i++){
if(check(i))ans+=s[i].val;
}
printf("%lld\n",ans);
return 0;
}
【题解】 bzoj2460: [BeiJing2011]元素 (线性基)
标签:scanf nod code fine div beijing efi its href
原文地址:https://www.cnblogs.com/Ning-Mew/p/9104842.html