From 706cf235fd1b9d8b5a8285dc57fb570e2587e88d Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Thu, 29 Sep 2022 08:30:14 +0800 Subject: [PATCH] B - Xor of 3 https://codeforces.com/contest/1572/submission/173868979 --- Codeforces/1572/B/B.cpp | 68 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Codeforces/1572/B/B.cpp diff --git a/Codeforces/1572/B/B.cpp b/Codeforces/1572/B/B.cpp new file mode 100644 index 00000000..2f717015 --- /dev/null +++ b/Codeforces/1572/B/B.cpp @@ -0,0 +1,68 @@ +#include +#include +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 2e5 + 5; + +int t, n, a[N], s[N]; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> t; + + while (t--) { + std::queue q; + + cin >> n; + + for (int i = 1; i <= n; i++) { + cin >> a[i]; + } + + std::partial_sum(a + 1, a + 1 + n, s + 1, std::bit_xor<>()); + + auto process = [&](int l, int r) -> void { + for (int i = r - 2; i >= l; i -= 2) q.emplace(i); + for (int i = l; i < r; i += 2) q.emplace(i); + }; + + if (!s[n]) { + if (n % 2) { + process(1, n); + } else { + for (int i = 1; i <= n; i += 2) { + if (!s[i]) { + process(1, i); + process(i + 1, n); + break; + } + } + } + } + + if (!q.empty()) { + cout << "YES" << endl + << q.size() << endl; + + while (!q.empty()) { + cout << q.front() << ' '; + q.pop(); + } + + cout << endl; + } else { + cout << "NO" << endl; + } + } + + return 0; +}