## Day 1

### 异或粽子

#### 代码

#include <bits/stdc++.h>
using namespace std;
const int maxn=5e5+1;
typedef long long ll;

ll x=0;char ch=getchar();
while(!isdigit(ch)) ch=getchar();
while(isdigit(ch)) x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
return x;
}

struct node{
int id,k;ll val;
node(int a=0,int b=0,ll c=0){
id=a,k=b,val=c;
}
bool operator < (const node &x) const{
return val<x.val;
}
};

int n,k;
ll a[maxn],ans;
int t[maxn<<5][2],siz[maxn<<5],tot;
priority_queue<node>q;

void insert(ll x){
int pos=0;
for (int i=31;i>=0;--i){
int son=(x>>i)&1;
siz[pos]++;
if (!t[pos][son])
t[pos][son]=++tot;
pos=t[pos][son];
}
siz[pos]++;
}

ll query(ll x,int rank){
int pos=0;ll ans=0;
for (int i=31;i>=0;--i){
int son=(x>>i)&1;
if (!t[pos][son^1])
pos=t[pos][son];
else if (rank<=siz[t[pos][son^1]])
pos=t[pos][son^1],ans|=1ll<<i;
else rank-=siz[t[pos][son^1]],pos=t[pos][son];
}
return ans;
}

int main(){
for (int i=1;i<=n;++i)
for (int i=0;i<=n;++i)
insert(a[i]);
for (int i=0;i<=n;++i)
q.push(node(i,1,query(a[i],1)));
for (int i=1;i<=2*k;++i){
node u=q.top();
ans+=u.val;q.pop();
if (u.k>=n) continue;
q.push(node(u.id,u.k+1,query(a[u.id],u.k+1)));
}
printf("%lld\n",ans/2);
}

## Day 2

### 春节十二响

#### 代码

#include <bits/stdc++.h>
#define chkmax(a,b) (b>a?a=b:0)
using namespace std;
const int maxn=2e5+1;
const int inf=1e9+1;
typedef long long ll;

int x=0;char ch=getchar();
while(!isdigit(ch)) ch=getchar();
while(isdigit(ch)) x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
return x;
}

priority_queue<int>q[maxn];
vector<int>son[maxn];

int sta[maxn],top,cnt;
int n,fa[maxn],val[maxn],cur[maxn];
ll ans;

void solve(int u){
cur[u]=++cnt;
for (auto v:son[u]){
solve(v);
if (q[cur[u]].size()<q[cur[v]].size())
swap(cur[u],cur[v]);
top=q[cur[v]].size();
for (int i=1;i<=top;++i){
sta[i]=max(q[cur[u]].top(),q[cur[v]].top());
q[cur[u]].pop();q[cur[v]].pop();
}
for (int i=1;i<=top;++i) q[cur[u]].push(sta[i]);
}
q[cur[u]].push(val[u]);
}

int main(){
}