Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** _ _______
- | | |____ /
- | | / /
- | | / /
- | |____ / /
- |______| /_/
- **/
- #include<bits/stdc++.h>
- using namespace std;
- void dbg_out(){
- cerr<<endl;
- }
- template <typename Head,typename... Tail>
- void dbg_out(Head H,Tail... T){
- cerr<<' '<<H;
- dbg_out(T...);
- }
- #define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
- typedef long long ll;
- typedef long double ld;
- typedef vector<ll>vl;
- typedef deque<ll>dq;
- typedef pair<ll,ll>pl;
- #define yes {cout<<"YES"<<endl;return;}
- #define no {cout<<"NO"<<endl;return;}
- #define CR(_) {cout<<_<<endl;return;}
- #define F first
- #define S second
- #define pb push_back
- #define ppb pop_back
- #define pf push_front
- #define ppf pop_front
- #define aff(v) for(auto e:v) cout<<e<<" ";cout<<endl;
- #define all(v) v.begin(), v.end()
- #define rall(v) v.rbegin(), v.rend()
- //const ll MOD = LLONG_MAX;
- //const ll MOD = 998244353;
- const ll MOD=1000000007;
- const ld eps=1e-7;
- const double PI=acos(-1);
- const int N=2e5+5;
- const ll INF=1e18;
- const int L=log2(N)+1;
- string to_bin(ll n){
- string ch="";
- while(n>0){
- char a=n%2+'0';
- ch=a+ch;
- n=n/2;
- }
- return ch;
- }
- int to_dec(string ch){
- int res=0;
- for(int i=ch.size()-1;i>=0;i--){
- int a=ch[i]-'0';
- int p=ch.size()-i-1;
- if(a)res+=1<<p;
- }
- return res;
- }
- void solve(){
- int n;cin>>n;
- int k;cin>>k;
- vector<int>v(n);
- for(int i=0;i<n;i++)cin>>v[i];
- string shit="";
- for(int i=0;i<k;i++){
- shit+='1';
- }
- for(int i=k;i<10;i++){
- shit+='0';
- }
- int ans=to_dec(shit);
- int op=0;
- vector<bool>vis(1024,0);
- vector<int>vect;vect.pb(0);
- vector<bool>done(1024);
- vis[0]=1;
- for(int i=0;i<n;i++){
- op=v[i]^op;
- if(vis[op])continue;
- for(auto j:vect){
- int cur=op^j;
- ans=max(ans,cur);
- if(done[cur])continue;
- else done[cur]=1;
- string bin=to_bin(cur);
- while(bin.size()<10)bin='0'+bin;
- int alpha=k;
- for(int f=0;f<10;f++){
- if(alpha==0)break;
- if(bin[f]=='0'){
- bin[f]='2';alpha--;
- }
- }
- for(int f=9;f>=0;f--){
- if(alpha==0)break;
- if(bin[f]=='1'){
- bin[f]='0';alpha--;
- }
- }
- for(int f=0;f<10;f++)if(bin[f]=='2')bin[f]='1';
- ans=max(ans,to_dec(bin));
- }
- if(!vis[op]){
- vis[op]=1;
- vect.pb(op);
- }
- }
- cout<<ans<<endl;
- }
- int main(){
- ios_base::sync_with_stdio(false);cin.tie(0);
- int _=1;
- cin>>_;
- //cout<<fixed<<setprecision(6);
- while(_--)solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement