QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#730158 | #9575. $P \oplus Q = R$ | ucup-team3924# | WA | 3ms | 3636kb | C++20 | 1.5kb | 2024-11-09 18:55:21 | 2024-11-09 18:55:22 |
Judging History
answer
#include <bits/stdc++.h>
int main() {
int t;
std::cin >> t;
while (t--) {
int n;
std::cin >> n;
if (n == 1) {
std::cout << "Yes\n0\n0\n";
continue;
}
if (n == 2) {
std::cout << "No\n";
continue;
}
if ((n & (n - 1)) != 0) {
std::cout << "No\n";
continue;
}
std::cout << "Yes\n";
for (int i = 0; i < n; i++)
std::cout << i << " ";
std::cout << "\n";
for (int i = 0; i < n / 2; i++)
std::cout << i * 2 << " ";
for (int i = 0; i < n / 2; i++) {
std::cout << ((i * 2 + 1) ^ 2) << " ";
}
std::cout << "\n";
}
return 0;
int n;
std::cin >> n;
std::vector<int> pa, pb;
for (int i = 0; i < n; i++) {
pa.push_back(i);
pb.push_back(i);
}
for (int i = 0; i < n / 2; i++) {
pb[i] = i * 2;
pb[i + n / 2] = (i * 2 + 1) ^ 2;
}
do {
std::vector<int> pc;
for (int i = 0; i < n; i++)
pc.push_back(pa[i] ^ pb[i]);
std::sort(pc.begin(), pc.end());
bool ok = true;
for (int i = 0; i < n; i++)
if (pc[i] != i)
ok = false;
if (ok) {
std::cerr << "Found solution!\n";
for (int i = 0; i < n; i++)
std::cerr << pa[i] << " ";
std::cerr << "\n";
for (int i = 0; i < n; i++)
std::cerr << pb[i] << " ";
std::cerr << "\n";
return 0;
}
} while (std::next_permutation(pb.begin(), pb.end()));
std::cerr << "No solution\n";
return 0;
}
详细
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: 3ms
memory: 3636kb
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 2 4 6 3 1 7 5 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 2 4 6 8 10 12 14 3 1 7 5 11 9 15 13 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)