标签:ble mat lin span tar tor 传送门 string new
分析
对法力值从大到小排序然后对编号跑线性基即可
代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
struct node {
long long sum;
int val;
};
node d[1100];
long long belong[110];
inline bool cmp(node x,node y){return x.val>y.val;}
int main(){
int n,m,i,j,Ans=0;
scanf("%d",&n);
for(i=1;i<=n;i++)scanf("%lld%d",&d[i].sum,&d[i].val);
sort(d+1,d+n+1,cmp);
for(i=1;i<=n;i++){
long long k=d[i].sum;
for(j=60;j>=0;j--)
if((1ll<<j)&k){
if(!belong[j]){
belong[j]=k;
Ans+=d[i].val;
break;
}
k^=belong[j];
}
}
printf("%d\n",Ans);
return 0;
}
标签:ble mat lin span tar tor 传送门 string new
原文地址:https://www.cnblogs.com/yzxverygood/p/10128875.html