77952024-01-11 10:20:42Albertstein992015. októbercpp17Accepted 3ms3524 KiB
#include <bits/stdc++.h>
using namespace std;

unsigned long long fact(int k){
    if(k == 0) return 1;
    return k * fact(k - 1);
}

int main(){
    unsigned long long n, m;
    cin >> n >> m;
    m--;
    vector <int> h;
    for(int i = 0; i < n; i++){
        h.push_back(i + 1);
    }
    for(int i = n - 1; i >= 0; i--){
        cout << h[m / fact(i)] << " ";
        h.erase(h.begin() + int(m / fact(i)));
        m %= fact(i);
    }
}
1 - Accepted
Memory: 1808KiB
Time: 3ms

Program's output:
1 2 4 3 
Expected output:
1 2 4 3 
Checker output:
ok 4 number(s): "1 2 4 3"

2 - Accepted
Memory: 2004KiB
Time: 3ms

Program's output:
5 3 2 4 1 
Expected output:
5 3 2 4 1 
Checker output:
ok 5 number(s): "5 3 2 4 1"

3 - Accepted
Memory: 2256KiB
Time: 3ms

Program's output:
1 
Expected output:
1 
Checker output:
ok 1 number(s): "1"

4 - Accepted
Memory: 2364KiB
Time: 3ms

Program's output:
1 8 3 5 7 4 2 6 9 
Expected output:
1 8 3 5 7 4 2 6 9 
Checker output:
ok 9 numbers

5 - Accepted
Memory: 2548KiB
Time: 3ms

Program's output:
1 8 10 2 3 12 4 6 7 5 9 11 
Expected output:
1 8 10 2 3 12 4 6 7 5 9 11 
Checker output:
ok 12 numbers

6 - Accepted
Memory: 2628KiB
Time: 3ms

Program's output:
7 3 1 5 8 9 10 11 2 6 4 
Expected output:
7 3 1 5 8 9 10 11 2 6 4 
Checker output:
ok 11 numbers

7 - Accepted
Memory: 2636KiB
Time: 3ms

Program's output:
2 1 
Expected output:
2 1 
Checker output:
ok 2 number(s): "2 1"

8 - Accepted
Memory: 2876KiB
Time: 3ms

Program's output:
6 3 8 2 5 4 10 11 7 1 9 
Expected output:
6 3 8 2 5 4 10 11 7 1 9 
Checker output:
ok 11 numbers

9 - Accepted
Memory: 3096KiB
Time: 3ms

Program's output:
4 5 2 1 7 6 3 
Expected output:
4 5 2 1 7 6 3 
Checker output:
ok 7 numbers

10 - Accepted
Memory: 3064KiB
Time: 3ms

Program's output:
10 2 4 1 5 8 3 9 7 6 
Expected output:
10 2 4 1 5 8 3 9 7 6 
Checker output:
ok 10 numbers

11 - Accepted
Memory: 3192KiB
Time: 3ms

Program's output:
1 
Expected output:
1 
Checker output:
ok 1 number(s): "1"

12 - Accepted
Memory: 3316KiB
Time: 3ms

Program's output:
2 5 14 12 8 4 11 6 13 9 1 10 3 7 
Expected output:
2 5 14 12 8 4 11 6 13 9 1 10 3 7 
Checker output:
ok 14 numbers

13 - Accepted
Memory: 3296KiB
Time: 3ms

Program's output:
3 2 1 
Expected output:
3 2 1 
Checker output:
ok 3 number(s): "3 2 1"

14 - Accepted
Memory: 3432KiB
Time: 3ms

Program's output:
1 4 3 6 2 5 
Expected output:
1 4 3 6 2 5 
Checker output:
ok 6 numbers

15 - Accepted
Memory: 3516KiB
Time: 3ms

Program's output:
1 
Expected output:
1 
Checker output:
ok 1 number(s): "1"

16 - Accepted
Memory: 3516KiB
Time: 3ms

Program's output:
14 13 12 11 10 9 8 7 6 5 4 3 2 1 
Expected output:
14 13 12 11 10 9 8 7 6 5 4 3 2 1 
Checker output:
ok 14 numbers

17 - Accepted
Memory: 3524KiB
Time: 3ms

Program's output:
7 14 13 12 11 10 9 8 6 5 4 3 2 1 
Expected output:
7 14 13 12 11 10 9 8 6 5 4 3 2 1 
Checker output:
ok 14 numbers