题解:P12420 【MX-X12-T3】「ALFR Round 5」变换
前言
很有趣的一道题,但是样例有点水(TAT)。
正篇
首先题面是要求
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll t;
ll n, m, k;
ll a[1000006];
void work()
{
cin >> n >> m >> k;
for(int i = 1; i <= n; i++)
cin >> a[i];
ll x = 0;
for(int i = 0; i < 31; i++)
{
if((m & (1 << i)) == 0)
continue;
ll cnt = 0;
for(int j = 1; j <= n; j++)
cnt += ((a[j] & (1 << i)) > 0);
if(cnt % 2 == 0)
for(int j = 1; j <= n; j++)
if((a[j] & (1 << i)) == 0)
{
a[j] |= (1 << i);
break;
}
}
ll ans = 0;
for(int i = 1; i <= n; i++)
ans ^= a[i];
cout << ans << "\n";
return ;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
ll t;
cin >> t;
while(t--)
work();
return 0;
}