QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#786802#4252. Permutationisirazeev0 1ms3748kbC++231.5kb2024-11-26 23:35:322024-11-26 23:35:46

Judging History

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

  • [2024-11-26 23:35:46]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3748kb
  • [2024-11-26 23:35:32]
  • 提交

answer

#include <bits/stdc++.h>

#include "perm.h"

using namespace std;

void mul2(vector<int> &p) {
    p.emplace_back((int) p.size());
}

void add1(vector<int> &p) {
    for (int &i: p) i++;
    p.emplace_back(0);
}

bool isGood(vector<int> p) {
    int pos1, pos0;
    for (int i = 0; i < (int) p.size(); i++) {
        if (p[i] == 1) pos1 = i;
        if (p[i] == 0) pos0 = i;
    }
    return pos1 < pos0;
}

std::vector<int> construct_permutation(long long k) {
    if (k <= 10) {
        vector<int> res(k - 1);
        iota(res.begin(), res.end(), 0);
        reverse(res.begin(), res.end());
        return res;
    }
    vector<int> operations;
    while (k > 1) {
        operations.emplace_back(k % 4);
        k /= 4;
    }
    vector<int> res;
    if (operations.back() == 0) res = {0, 1};
    else if (operations.back() == 1) res = {1, 2, 0};
    else if (operations.back() == 2) res = {0};
    else res = {1, 0};
    operations.pop_back();
    reverse(operations.begin(), operations.end());
    for (int r: operations) {
        if (r == 0) {
            mul2(res), mul2(res);
        } else if (r == 1) {
            mul2(res), mul2(res), add1(res);
        } else if (r == 2) {
            mul2(res), add1(res), mul2(res);
        } else {
            if (isGood(res)) {
                mul2(res), mul2(res);
                for (int &i: res)
                    if (i > 1) ++i;
                res.emplace_back(2);
            } else {
                mul2(res), add1(res), mul2(res), add1(res);
            }
        }
    }
    return res;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3728kb

input:

a92b3f80-b312-8377-273c-3916024d7f2a
89
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

output:

6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf
OK
1
0
2
1 0
3
2 1 0
4
3 2 1 0
5
4 3 2 1 0
6
5 4 3 2 1 0
7
6 5 4 3 2 1 0
8
7 6 5 4 3 2 1 0
9
8 7 6 5 4 3 2 1 0
5
2 3 1 4 0
4
1 0 2 3
5
2 1 3 4 0
5
2 1 3 0 4
5
1 0 3 4 2
4
0 1 2 3
5
1 2 3 4 0
5
1 2 3 0 4
6
2 3 4 1 5 0
5
1 2 0 3 4
6
2 3 1 4 5 0
6
2 3 1 4 0 5
6
1 3 ...

result:

wrong answer 

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 3748kb

input:

a92b3f80-b312-8377-273c-3916024d7f2a
100
39993
85709
48645
25391
15360
54084
28947
18808
86735
316
14357
82845
96210
16242
58466
43439
77462
70742
76176
20397
30314
22634
29622
81835
31904
81283
37072
36527
26764
55878
72762
5262
34915
63468
20595
66579
77373
36670
89340
83384
73268
31960
67318
3908...

output:

6cad0f33-b1bd-3a3e-1a8d-c4af23adfcbf
OK
20
3 6 7 2 8 9 5 10 11 12 13 14 15 4 16 1 17 18 19 0
22
5 7 2 8 9 10 11 6 12 1 13 14 15 4 16 17 18 19 3 20 21 0
21
6 7 4 8 3 9 10 5 11 2 12 13 14 15 16 17 18 1 19 20 0
18
5 6 7 8 4 9 1 10 11 12 0 13 14 15 3 16 17 2
15
1 0 3 4 2 5 6 7 8 9 10 11 12 13 14
20
5 3 ...

result:

wrong answer