#include #include #define rep(i,b) for(int i=0;i=0;i--) #define rep1(i,b) for(int i=1;i=x;i--) #define fore(i,a) for(auto& i:a) #define rng(x) (x).begin(), (x).end() #define rrng(x) (x).rbegin(), (x).rend() #define sz(x) ((int)(x).size()) #define pb push_back #define fi first #define se second #define pcnt __builtin_popcountll using namespace std; using namespace atcoder; using ll = long long; using ld = long double; template using mpq = priority_queue, greater>; template bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (b ll sumv(const vector&a){ll res(0);for(auto&&x:a)res+=x;return res;} bool yn(bool a) { if(a) {cout << "Yes" << endl; return true;} else {cout << "No" << endl; return false;}} #define retval(x) {cout << #x << endl; return;} #define cout2(x,y) cout << x << " " << y << endl; #define coutp(p) cout << p.fi << " " << p.se << endl; #define out cout << ans << endl; #define outd cout << fixed << setprecision(20) << ans << endl; #define outm cout << ans.val() << endl; #define outv fore(yans , ans) cout << yans << "\n"; #define outdv fore(yans , ans) cout << yans.val() << "\n"; #define assertmle(x) if (!(x)) {vi v(3e8);} #define asserttle(x) if (!(x)) {while(1){}} #define coutv(v) {fore(vy , v) {cout << vy << " ";} cout << endl;} #define coutv2(v) fore(vy , v) cout << vy << "\n"; #define coutvm(v) {fore(vy , v) {cout << vy.val() << " ";} cout << endl;} #define coutvm2(v) fore(vy , v) cout << vy.val() << "\n"; using pll = pair;using pil = pair;using pli = pair;using pii = pair;using pdd = pair; using vi = vector;using vd = vector;using vl = vector;using vs = vector;using vb = vector; using vpii = vector;using vpli = vector;using vpll = vector;using vpil = vector; using vvi = vector>;using vvl = vector>;using vvs = vector>;using vvb = vector>; using vvpii = vector>;using vvpli = vector>;using vvpll = vector;using vvpil = vector; using mint = modint998244353; //using mint = modint1000000007; //using mint = dynamic_modint<0>; using vm = vector; using vvm = vector>; vector dx={1,0,-1,0,1,1,-1,-1},dy={0,1,0,-1,1,-1,1,-1}; ll gcd(ll a, ll b) { return a?gcd(b%a,a):b;} ll lcm(ll a, ll b) { return a/gcd(a,b)*b;} #define yes {cout <<"Yes"< struct BinaryTrie { using Container = vector; struct Node { Node *nxt[2]; int exist; Container accept; Node() {} }; Node *pool; int pid; T lazy; Node *nil; Node *root; int num; BinaryTrie() : pid(0), lazy(T(0)), nil(nullptr), num(0) { pool = new Node[NODES]; nil = my_new(); nil->nxt[0] = nil->nxt[1] = root = nil; } Node *my_new(int exist_ = 0, int id = -1) { pool[pid].nxt[0] = pool[pid].nxt[1] = nil; pool[pid].exist = exist_; if (id != -1) pool[pid].accept.push_back(id); return &(pool[pid++]); } Node *merge(Node *l, Node *r) { pool[pid].nxt[0] = l; pool[pid].nxt[1] = r; pool[pid].exist = l->exist + r->exist; return &(pool[pid++]); } private: Node *add_(const T &x, int id, Node *n, int bit_idx) { if (bit_idx == -1) { if (n == nil) return my_new(1, id); n->exist++; n->accept.push_back(id); return n; } else { if (((lazy >> bit_idx) & 1) == ((x >> bit_idx) & 1)) return merge(add_(x, id, n->nxt[0], bit_idx - 1), n->nxt[1]); else return merge(n->nxt[0], add_(x, id, n->nxt[1], bit_idx - 1)); } } public: void add(const T &x, int id = -1) { assert(x >= 0); num++; assert(num < NODES); root = add_(x, id, root, MAX_LOG); } private: pair find_(const T &x, Node *n, int bit_idx) { if (bit_idx == -1) return pair(n->exist, n->accept); else { if (((lazy >> bit_idx) & 1) == ((x >> bit_idx) & 1)) return find_(x, n->nxt[0], bit_idx - 1); else return find_(x, n->nxt[1], bit_idx - 1); } } public: pair find(const T &x) { return find_(x, root, MAX_LOG); } private: Node *del_(const T &x, int id, Node *n, int bit_idx) { if (bit_idx == -1) { n->exist--; return n; } else { if (((lazy >> bit_idx) & 1) == ((x >> bit_idx) & 1)) return merge(del_(x, id, n->nxt[0], bit_idx - 1), n->nxt[1]); else return merge(n->nxt[0], del_(x, id, n->nxt[1], bit_idx - 1)); } } public: void del(const T &x, int id = -1) { num--; assert(find(x).fi != 0); root = del_(x, id, root, MAX_LOG); } private: pair max_element_(Node *n, int bit_idx) { if (bit_idx == -1) return pair(0, n->accept); if (n->nxt[~(lazy >> bit_idx) & 1]->exist) { auto ret = max_element_(n->nxt[~(lazy >> bit_idx) & 1], bit_idx - 1); ret.first |= T(1) << bit_idx; return ret; } else { return max_element_(n->nxt[(lazy >> bit_idx) & 1], bit_idx - 1); } } public: pair max_element() { assert(num > 0); return max_element_(root, MAX_LOG); } private: pair min_element_(Node *n, int bit_idx) { if (bit_idx == -1) return pair(0, n->accept); if (n->nxt[(lazy >> bit_idx) & 1]->exist) { return min_element_(n->nxt[(lazy >> bit_idx) & 1], bit_idx - 1); } else { auto ret = min_element_(n->nxt[~(lazy >> bit_idx) & 1], bit_idx - 1); ret.first |= T(1) << bit_idx; return ret; } } public: pair min_element() { assert(num > 0); return min_element_(root, MAX_LOG); } private: pair get_kth_(Node *n, int64_t k, int bit_idx) { if (bit_idx == -1) return pair(0, n->accept); int ex0 = n->nxt[(lazy >> bit_idx) & 1]->exist; if (ex0 < k) { auto ret = get_kth_(n->nxt[~(lazy >> bit_idx) & 1], k - ex0, bit_idx - 1); ret.first |= T(1) << bit_idx; return ret; } else { return get_kth_(n->nxt[(lazy >> bit_idx) & 1], k, bit_idx - 1); } } public: pair get_kth(int64_t k) { assert(k < num); return get_kth_(root, k + 1, MAX_LOG); } void operate_xor(T x) { lazy ^= x; } }; // BinaryTrie trie : 宣言方法。 // addする要素の数をnとしたとき n * LogMax < NODES となるように。MLE注意。インスタンスを複数用意する場合はNODESを小さくする。 // add(x , id) : idをインデックスとしてもつxを木に追加 // del(x , id) : idをインデックスとしてもつxを木から削除 // find(x) : 木にxが存在するかどうか。返り値はpair(個数,インデックスの集合) // max_element()/min_element() : 最大値/最小値を返す。返り値はpair(最大値/最小値,インデックスの集合) // get_kth() : k番目(0-Origin & 昇順)の値を返す。返り値はpair(値,インデックスの集合) // operate_xor(x) : 集合全体にxorを作用させる。 // 配列外アクセスは全てアサートが出る。 // インデックスの集合はvi型で受け取れる。 void solve(){ int n,k; cin>>n>>k; vi a(n); rep(i,n) cin>>a[i]; map mp; int lmx = -1; int rmn = INF; mp[0] = 0; int s = 0; rep(i,n){ s ^= a[i]; if (mp.count(s)){ chmax(lmx, mp[s]); chmin(rmn, i); } mp[s] = i+1; } BinaryTrie bt; s = 0; rep1(i,n){ s ^= a[i]; bt.add(s); } multiset rs,ls; vi rsum(n),lsum(n); auto upd = [&](int id)->void{ if (id >= n-1) return; bt.operate_xor(a[id]); bt.operate_xor(a[id+1]); ls.insert(lsum[id]); if (id < n-1){ auto it = rs.lower_bound(rsum[id+1]); rs.erase(it); } }; rep(i,n){ lsum[i] = a[i]; if (i) lsum[i] ^= lsum[i-1]; } rrep(i,n){ rsum[i] = a[i]; if (ibool{ if (x <= 0) return false; if (ls.find(x) != ls.end()) return false; if (rs.find(x) != rs.end()) return false; int k = bt.find(x).fi; return k == 0; }; rep1(i,n) rs.insert(rsum[i]); bool ok = false; rep(i,n){ if (i < lmx || i > rmn){ upd(i); continue; } rep(j,k+1){ int k1 = a[i] + j; int k2 = a[i] - j; if (isOK(k1)) ok = true; if (isOK(k2)) ok = true; } upd(i); } yn(ok); return; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int t = 1; //cin>>t; rep(i,t){ solve(); } return 0; }