QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623338#9428. Be PositiveSlinkWA 0ms3552kbC++14789b2024-10-09 11:24:572024-10-09 11:24:58

Judging History

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

  • [2024-10-09 11:24:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2024-10-09 11:24:57]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define int ll
#define vi vector<int>

const int INF = 1e18 + 5;

bool check(int n) {
    return n - (n & -n);
}


void solve()
{
    int n;
    cin >> n;
    if (n != 2 && !check(n)) {
        cout << "impossible\n";
        return;
    }

    vi a(n);
    for (int i=0; i<n; i++)
        a[i] = i;
    
    swap(a[0], a[1]);
    for (int i=4; i<n - 1; i++) {
        if (!check(i)) {
            swap(a[i], a[i - 1]);
        }
    }

    for (int i=0; i<n; i++) 
        cout << a[i] << ' ';
    cout << '\n';
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3552kb

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

input:

10
1
2
3
4
5
6
7
8
9
10

output:

impossible
1 0 
1 0 2 
impossible
1 0 2 3 4 
1 0 2 4 3 5 
1 0 2 4 3 5 6 
impossible
1 0 2 4 3 5 6 7 8 
1 0 2 4 3 5 6 8 7 9 

result:

wrong answer xor equals zero (test case 5)