QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#605912 | #9428. Be Positive | shift | WA | 0ms | 3584kb | C++20 | 891b | 2024-10-02 20:35:01 | 2024-10-02 20:35:02 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
void solve() {
int n;
std::cin >> n;
int cur = 0;
std::vector<int> p;
for(int i = 0; i < n; i ++ ) {
if((cur ^ i) == 0) {
if(i == n - 1) {
std::cout << "imopssible" << '\n';
return;
}
cur ^= (i + 1) ^ i;
p.push_back(i + 1);
p.push_back(i);
i += 1;
} else {
cur ^= i;
p.push_back(i);
}
}
for(int i = 0; i < n; i ++ ) {
std::cout << p[i] << " \n"[i == n - 1];
}
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t = 1;
std::cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3584kb
input:
4 1 2 3 4
output:
imopssible 1 0 1 0 2 imopssible
result:
wrong answer not permutation (test case 1)