>>> 0^0^0 0 >>> 0^0^1 1 >>> 0^1^1 0 >>> 1^1^1 1
- 整个数列异或和为0时,无解
- 奇数乱搞
- 偶数长度时,将问题拆解成两个奇数长度且偶数xor和
#include <bits/stdc++.h> #define sc(x) scanf("%lld", &(x)) #define pr(x) printf("%lld\n", (x)) #define rep(i, l, r) for (int i = l; i <= r; ++i) using namespace std; typedef long long ll; const int N = 2e5 + 7; const int mod = 1e9 + 7; int n, t, a[N]; void out(int l, int r, vector<int>& a) { for (int i = r - 2; i >= l; i -= 2) a.push_back(i); for (int i = l; i < r; i += 2) a.push_back(i); } int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> t; while (t--) { cin >> n; vector<int> ans; for (int i = 1; i <= n; ++i) cin >> a[i], a[i] ^= a[i - 1]; if (!a[n]) { if (n & 1) out(1, n, ans); else for (int i = 1; i <= n; i += 2) if (a[i] == 0) { out(1, i, ans); out(i + 1, n, ans); break; } } if (ans.size()) { cout << "YES\n" << ans.size() << '\n'; for (int x : ans) cout << x << ' '; cout << '\n'; } else cout << "NO\n"; } }