QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#727645 | #9575. $P \oplus Q = R$ | ucup-team5657# | WA | 1ms | 3796kb | C++14 | 1.9kb | 2024-11-09 13:30:15 | 2024-11-09 13:30:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define _rep(i_,a_,b_) for(int i_ = (a_); i_ <= (b_); ++i_)
#define mid ((L+R) >> 1)
#define multiCase() int testCnt = in(); _rep(curCase,1,testCnt)
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
using ll = long long;
using pii = pair<int,int>;
int in(void) { int x; scanf("%d", &x); return x; } ll inl(void) { ll x; scanf("%lld", &x); return x; }
void out(int x) { printf("%d ", x); } void outln(int x) { printf("%d\n", x); }
void out(ll x) { printf("%lld ", x); } void outln(ll x) { printf("%lld\n", x); }
template<typename T> void chkmax(T &a, const T &b) { a = max(a, b); }
template<typename T> void chkmin(T &a, const T &b) { a = min(a, b); }
int main() {
multiCase() {
int n = in();
if(n == 1) {
puts("Yes\n0\n0");
continue;
}
if((n & (n - 1)) || n <= 2) puts("No");
else {
puts("Yes");
vector<int> f = {0, 2, 3, 1};
while(f.size() != n) {
vector<int> g = f; for(auto &u : g) u += f.size();
vector<int> h(f.size() * 2);
_rep(i,0,f.size() / 2 - 1) h[i] = f[i];
_rep(i,0,f.size() / 2 - 1) h[i+f.size()/2] = g[i];
_rep(i,f.size()/2,f.size()-1)h[i+f.size()/2]=f[i];
_rep(i,f.size()/2,f.size()-1)h[i+f.size()]=g[i];
f = h;
}
_rep(i,0,n - 1) out(i); puts("");
_rep(i,0,n - 1) out(f[i]); puts("");
// vector<int> q(n);
// _rep(i,0,n - 1) q[i] = i ^ f[i];
// sort(q.begin(), q.end());
// _rep(i,0,n - 1) debug("%d%c", q[i], " \n"[i == n - 1]);
}
}
// int n = in();
// vector<int> p(n), q(n);
// _rep(i,0,n - 1) p[i] = i, q[i] = i;
// do {
// vector<int> r(n);
// _rep(i,0,n - 1) r[i] = p[i] ^ q[i];
// sort(r.begin(), r.end());
// if(r == p) {
// for(auto &u : r) out(u); puts("");
// for(auto &u : q) out(u); puts("");
// return 0;
// }
// } while(next_permutation(q.begin(), q.end()));
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3796kb
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: 1ms
memory: 3780kb
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)