QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#742436#9428. Be PositivefosovWA 0ms3808kbC++14968b2024-11-13 16:36:382024-11-13 16:36:42

Judging History

This is the latest submission verdict.

  • [2024-11-13 16:36:42]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3808kb
  • [2024-11-13 16:36:38]
  • Submitted

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';
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

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)