Submission #66388577
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(a) begin(a), end(a)
#define len(a) (int)((a).size())
const ll LG = 60, MX = (1ll << 60);
mt19937_64 rd(228);
struct sp {
vector<ll> bt;
sp() {
bt.resize(LG, -1);
}
void ins(ll v) {
for (int b = LG - 1; b >= 0; --b) {
if (!((v >> b) & 1)) continue;
if (bt[b] == -1) {
bt[b] = v;
return;
}
v ^= bt[b];
}
}
void merge(const sp& a) {
for (auto v : a.bt) ins(v);
}
bool find(ll v) {
for (int b = LG - 1; b >= 0; --b) {
if (!((v >> b) & 1)) continue;
if (bt[b] == -1) return false;
v ^= bt[b];
}
return true;
}
};
vector<sp> spaces;
vector<ll> vec;
vector<ll> ops, bad = {-1};
void apply(int i) {
assert(i + 1 < len(vec));
ll x = vec[i] ^ vec[i + 1];
vec[i] = x;
vec[i + 1] = x;
ops.push_back(i);
}
set<array<ll, 3>> vis;
bool dfs(int i, ll k) {
if (i > len(vec) || len(ops) >= 10'000) return false;
if (i == len(vec)) {
if (k == 0) {
return true;
} else {
return false;
}
}
if (vis.count({i, vec[i], k})) return false;
vis.insert({i, vec[i], k});
if (vec[i] == k) {
return true;
}
if (i == len(vec)) return false;
if (dfs(i + 1, k ^ vec[i])) {
apply(i);
return true;
}
for (int t = 2; ; ++t) {
ops.push_back(i + t - 2);
ops.push_back(i + t - 2);
if (i + t <= len(vec)) {
if (i + t == len(vec)) {
if (dfs(i + t, k)) {
for (int j = i; j < i + t; ++j) vec[j] = 0;
return true;
}
} else {
if (dfs(i + t + 1, k ^ vec[i + t])) {
for (int j = i; j < i + t; ++j) vec[j] = 0;
for (int j = i + t - 1; j >= i; --j) {
apply(j);
}
return true;
}
}
} else {
for (int j = 2; j <= t; ++j) {
ops.pop_back(); ops.pop_back();
}
return false;
}
}
return false;
}
void solve() {
ll n, k;
cin >> n >> k;
//n = 30;
//k = rd() % MX;
vec.resize(n);
for (auto &c : vec) {
cin >> c;
//c = rd() % MX;
}
vis.clear();
// spaces.clear();
// spaces.resize(n + 1);
// spaces[n - 1].ins(vec.back());
// for (int i = n - 2; i >= 0; --i) {
// spaces[i].merge(spaces[i + 2]);
// if (i + 3 <= n) spaces[i].merge(spaces[i + 3]);
// for (auto v : spaces[i + 1].bt) {
// spaces[i].ins(v ^ vec[i]);
// }
// spaces[i].ins(vec[i]);
// }
ops.clear();
if (dfs(0, k)) {
cout << "Yes\n";
assert(vec[0] == k);
cout << len(ops) << "\n";
for (auto c : ops) cout << c + 1 << " ";
cout << "\n";
} else {
cout << "No\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Adjacent Replace |
| User | Tea_Time |
| Language | C++ 20 (gcc 12.2) |
| Score | 0 |
| Code Size | 3445 Byte |
| Status | RE |
| Exec Time | 2219 ms |
| Memory | 171140 KiB |
Judge Result
| Set Name | Sample | All | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 800 | ||||||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt |
| All | 00_sample_00.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3424 KiB |
| 01_test_00.txt | RE | 130 ms | 3520 KiB |
| 01_test_01.txt | RE | 77 ms | 3796 KiB |
| 01_test_02.txt | TLE | 2215 ms | 145336 KiB |
| 01_test_03.txt | TLE | 2219 ms | 167184 KiB |
| 01_test_04.txt | TLE | 2213 ms | 95384 KiB |
| 01_test_05.txt | RE | 80 ms | 4132 KiB |
| 01_test_06.txt | TLE | 2216 ms | 165276 KiB |
| 01_test_07.txt | TLE | 2216 ms | 162008 KiB |
| 01_test_08.txt | WA | 10 ms | 3684 KiB |
| 01_test_09.txt | TLE | 2215 ms | 137200 KiB |
| 01_test_10.txt | TLE | 2216 ms | 166636 KiB |
| 01_test_11.txt | TLE | 2216 ms | 163156 KiB |
| 01_test_12.txt | TLE | 2216 ms | 165004 KiB |
| 01_test_13.txt | RE | 77 ms | 3520 KiB |
| 01_test_14.txt | TLE | 2217 ms | 171140 KiB |
| 01_test_15.txt | TLE | 2216 ms | 159060 KiB |
| 01_test_16.txt | TLE | 2216 ms | 164976 KiB |
| 01_test_17.txt | TLE | 2216 ms | 167416 KiB |
| 01_test_18.txt | TLE | 2216 ms | 160168 KiB |
| 01_test_19.txt | TLE | 2216 ms | 166148 KiB |
| 01_test_20.txt | TLE | 2215 ms | 134188 KiB |
| 01_test_21.txt | TLE | 2215 ms | 149444 KiB |
| 01_test_22.txt | TLE | 2216 ms | 165300 KiB |
| 01_test_23.txt | TLE | 2216 ms | 168552 KiB |
| 01_test_24.txt | RE | 77 ms | 3632 KiB |
| 01_test_25.txt | RE | 76 ms | 3488 KiB |
| 01_test_26.txt | RE | 75 ms | 3516 KiB |
| 01_test_27.txt | RE | 76 ms | 3532 KiB |
| 01_test_28.txt | RE | 76 ms | 3468 KiB |
| 01_test_29.txt | RE | 76 ms | 3540 KiB |
| 01_test_30.txt | TLE | 2216 ms | 159384 KiB |
| 01_test_31.txt | TLE | 2216 ms | 162924 KiB |
| 01_test_32.txt | TLE | 2216 ms | 166128 KiB |