QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#742436 | #9428. Be Positive | fosov | WA | 0ms | 3808kb | C++14 | 968b | 2024-11-13 16:36:38 | 2024-11-13 16:36:42 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define INF 0x3f3f3f3f
#define LNF 0x3f3f3f3f3f3f3f3fll
#define MOD 998244353
#define pii pair<int, int>
#define N 100010
#define K 20
ll val(ll x, ll k) {
return (x + k - 1) / k * k - x;
}
int main() {
#ifdef TEST
freopen("zz.in", "r+", stdin);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t; cin >> t;
while (t --) {
int n; cin >> n;
vector<int> p(n);
iota(p.begin(), p.end(), 0);
int xr = 0;
for (auto x : p) xr ^= x;
if (xr == 0) {
cout << "impossible\n";
} else {
xr = 0;
for (int i = 0; i < n - 1; ++ i) {
if (xr ^ p[i] == 0) swap(p[i], p[i+1]);
xr ^= p[i];
}
for (auto x : p) cout << x << ' ';
cout << '\n';
}
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3728kb
input:
4 1 2 3 4
output:
impossible 1 0 1 0 2 impossible
result:
ok 4 test cases (4 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3808kb
input:
10 1 2 3 4 5 6 7 8 9 10
output:
impossible 1 0 1 0 2 impossible 1 0 3 4 2 1 0 3 4 5 2 1 0 3 4 5 6 2 impossible 1 0 3 4 5 6 7 8 2 1 0 3 4 5 6 7 8 9 2
result:
wrong answer Jury has better answer (test case 5)