QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#627160 | #9428. Be Positive | shiqiaqiaya# | WA | 75ms | 3764kb | C++17 | 2.0kb | 2024-10-10 15:00:30 | 2024-10-10 15:00:30 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define int long long
using i64 = long long;
using i128 = __int128;
using f64 = double;
using f128 = long double;
constexpr i64 mod = [](bool n) { return n ? 998244353 : 1e9 + 7; } (1);
mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());
template <class K, class C = less<>> using paring_heap = __gnu_pbds::priority_queue<K, C>;
template <class K> using rb_tree = tree<K, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
ostream & operator << (ostream & os, i128 t) {
string s;
for (; t; s += '0' + t % 10, t /= 10);
return reverse(s.begin(), s.end()), os << s;
}
template <class T, class ... A> void debug(T t, A ... a) { cerr << "[" << t, ((cerr << ", " << a), ...), cerr << "]\n"; }
template <i64 mod = mod> i64 binpow(i64 a, i64 b, i64 res = 1) {
for (a %= mod; b; b >>= 1, (a *= a) %= mod) {
if (b & 1) (res *= a) %= mod;
}
return res;
}
void QAQ() {
int n;
cin >> n;
vector<int> p(n); iota(p.begin(), p.end(), 0);
int sum = 0;
for (auto & x : p) {
sum ^= x;
}
if (sum == 0) return cout << "impossible\n", void();
set<int> s(p.begin(), p.end());
int now = 0, i = 0;
for ( ; s.size(); ) {
if (now == *s.begin()) {
cout << (1ll << i) << " ";
now ^= 1ll << i;
s.erase(1ll << i);
i++;
} else {
int t = __builtin_popcount(*s.begin());
if (t == 1) {
i++;
}
cout << *s.begin() << " ";
now ^= *s.begin();
s.erase(s.begin());
}
}
cout << "\n";
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
int t = 1;
cin >> t;
for (cout << fixed << setprecision(12); t--; QAQ());
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
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: 0
Accepted
time: 0ms
memory: 3604kb
input:
10 1 2 3 4 5 6 7 8 9 10
output:
impossible 1 0 1 0 2 impossible 1 0 2 4 3 1 0 2 4 3 5 1 0 2 4 3 5 6 impossible 1 0 2 4 3 5 6 8 7 1 0 2 4 3 5 6 8 7 9
result:
ok 10 test cases (10 test cases)
Test #3:
score: -100
Wrong Answer
time: 75ms
memory: 3764kb
input:
1413 1392 1306 297 726 1353 1059 111 758 1409 843 1013 940 1186 788 60 230 1249 209 776 966 178 25 168 494 70 867 601 195 718 497 1161 323 1054 265 148 388 186 539 760 1184 1230 829 400 460 1253 922 903 42 1347 1368 404 512 1170 378 136 560 1078 612 1201 30 717 934 572 975 255 1131 319 629 264 1240 ...
output:
impossible 1 0 2 4 3 5 6 8 7 9 10 16 11 12 13 14 15 17 18 32 19 20 21 22 23 24 25 26 27 28 29 30 31 33 34 64 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 65 66 128 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 9...
result:
wrong answer Integer parameter [name=x] equals to 2048, violates the range [0, 1305] (test case 2)