QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#627126#9428. Be Positiveshiqiaqiaya#WA 1ms3688kbC++171.9kb2024-10-10 14:52:182024-10-10 14:52:18

Judging History

你现在查看的是最新测评结果

  • [2024-10-10 14:52:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3688kb
  • [2024-10-10 14:52:18]
  • 提交

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 t = __lg(n);

    for (int i = 0; i < t + 1; i++) {
        if (s.count(1ll << i)) {
            s.erase(1ll << i);
            cout << (1ll << i) << " ";
        }
        for ( ; s.size() && *s.begin() < (1ll << i); s.erase(s.begin())) {
            cout << *s.begin() << " ";
        }
    }

    while (s.size()) {
        cout << *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: 1ms
memory: 3608kb

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: 3688kb

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 8 5 6 7 
1 0 2 4 3 8 5 6 7 9 

result:

wrong answer Jury has better answer (test case 9)