제출 #588882

#제출 시각아이디문제언어결과실행 시간메모리
588882fuad27XOR (IZhO12_xor)C++17
0 / 100
9 ms1876 KiB
/*
 * Created: 2022-07-04 10:04
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
using namespace chrono;
// using namespace atcoder

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
const ll inf = 1e18;

#define pii		pair<int,int>
#define pll		pair<ll,ll>
#define vi		vector<int>
#define vll		vector<ll>
#define rep(i, a, b)	for(int i = (a);i<(b);i++)
#define repn(i, a, b)	for(int i = (a);i>=(b);i--)
#define ss		second
#define ff		first
#define mkp		make_pair
#define pb		push_back

#define all(x)		(x).begin(), (x).end()
struct node {
	node* child[2];
	ll idx;
	node() {
		child[0]=child[1]=nullptr;
		idx=inf;
	}
};
void insert(node*& root, ll a,ll idx, int bit) {
	if(root==nullptr) {
		root = new node();
	}
	root->idx=min(root->idx,idx);
	if(bit == -1)return;
	if((a&(1ll<<bit))) {
		insert(root->child[1], a,idx, bit-1);
	}
	else {
		insert(root->child[0], a, idx, bit-1);
	}
}
long long find(node*& root, ll a, ll x, int bit) {
	if(root==nullptr) {
		return inf;
	}
	if(bit == -1)return root->idx;
	if(x == 0)return root->idx;
	if(((1ll<<bit)&a)) {
		if(((1ll<<bit)&x)) {
			return find(root->child[0], a, x, bit-1);
		}
		else {
			return min(find(root->child[1],a, x, bit-1), find(root->child[0], 0, 0, bit-1));
		}
	}
	else {
		if(((1ll<<bit)&x)) {
			return find(root->child[1], a, x, bit-1);
		}
		else {
			return min(find(root->child[1], 0, 0, bit-1), find(root->child[0], a, x, bit-1));
		}
	}
}
void solve() {
	int n;
	ll x;
	cin >> n >> x;
	ll pref[n+1];
	pref[0]=0;
	rep(i, 0, n) {
		ll a;cin >> a;
		pref[i+1]=(pref[i]^a);
	}
	ll l=-1,r=-2;
	node* root=nullptr;
	rep(i, 0, n+1) {
		ll idx = find(root, pref[i], x, 30);
		insert(root, pref[i], i, 30);
		if(i-idx > r-l) {
			l=idx+1;
			r=i;
		}	
	}
	cout << l << " " << (r-l+1) << "\n";
}

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	while(t--) {
		solve();
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...