QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#730011 | #9575. $P \oplus Q = R$ | ucup-team5799 | WA | 19ms | 3808kb | C++20 | 1.6kb | 2024-11-09 18:17:44 | 2024-11-09 18:17:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void printArr(vector<int> ans) {
for (int x : ans) {
cout << x << " ";
}
cout << '\n';
}
void solve() {
int n; cin >> n;
if (n == 1) {
cout << "Yes" << '\n';
cout << 0 << '\n';
cout << 0 << '\n';
return;
}
int k = log2(n);
if ((1 << k) != n) {
cout << "No" << '\n';
return;
}
vector<int> id(n);
iota(id.begin(), id.end(), 0);
auto check = [&](vector<int> a) {
sort(a.begin(), a.end());
for (int i = 0;i < n;i++) {
if (a[i] != id[i]) return false;
}
return true;
};
vector<int> b(n);
for (int p = 0;p < n;p++) {
int i = p, j = 0;
do {
b[i] = j;
i = (i + 2) % n;
j++;
} while (i != p);
for (int q = (p & 1) ^ 1;q < n;q += 2) {
int ii = q, jj = n / 2;
do {
b[ii] = jj;
jj++;
ii = (ii - 2 + n) % n;
} while (ii != q);
vector<int> ans(n);
for (int i = 0;i < n;i++) {
ans[i] = id[i] ^ b[i];
}
// printArr(b);
if (check(ans)) {
cout << "Yes" << '\n';
printArr(id);
printArr(ans);
return;
}
}
}
cout << "No" << '\n';
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t; cin >> t;
while(t--) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
input:
2 3 4
output:
No Yes 0 1 2 3 0 2 3 1
result:
ok Correct. (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 19ms
memory: 3808kb
input:
1999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
Yes 0 0 No No Yes 0 1 2 3 0 2 3 1 No No No Yes 0 1 2 3 4 5 6 7 0 4 3 7 6 2 5 1 No No No No No No No Yes 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 14 3 13 6 8 5 11 12 2 15 1 10 4 9 7 No No No No No No No No No No No No No No No Yes 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ...
result:
wrong answer Testcase 12, n = 12, Jury has better solution. (test case 12)