1. 程式人生 > >牛客練習賽26 xor序列

牛客練習賽26 xor序列

define include 序列 test int base contest std bsp

xor序列

思路:線性基

代碼:

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define
rs rt<<1|1, m+1, r #define ULL unsigned LL #define pll pair<LL, LL> #define pii pair<int, int> #define piii pair<pii, int> #define mem(a, b) memset(a, b, sizeof(a)) #define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout); //
head const int N = 1e5 + 5; vector<int> base; int main() { int n, t, q, a, b; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &t); for (int j = 0; j < base.size(); j++) if((t^base[j]) < t) t ^= base[j]; if(t) base.pb(t); } scanf(
"%d", &q); while(q--) { scanf("%d %d", &a, &b); a ^= b; for (int i = 0; i < base.size(); i++) if((a^base[i]) < a) a ^= base[i]; if(a) puts("NO"); else puts("YES"); } return 0; }

牛客練習賽26 xor序列